The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

CONTROL FILES

Control files define the format of data files. Each line specifies a field in the data file:

  • The field name.

  • Whether the field is nullable.

  • Validation rules. These are only required by the validate plugin.

Example Control File

    custname   N    varchar(20)
    cost       Y    integer
    phone      Y    qr/^\d{3}-\d{4}$/
    city       N    qr/^(Auckland|Wellington)$/
    rec_date   N    date(%Y-%m-%d %H:%M:%S)   
    period     N    integer;range(1,50)
  • custname is mandatory, and can be up to 20 characters in length.

  • cost is optional and is an integer.

  • The phone number is optional, but if it exists it must match the specified regular expression.

  • The city is mandatory must be either Auckland or Wellington.

  • The rec_date must comply with the specified POSIX date format.

  • The period must be an integer, and must be between one and fifty.

VALIDATION RULES

A field can have multiple rules, each separated by a semi-colon. The possible rules are:

  • varchar(n). A variable number of characters, up to the value of n. Example: varchar(200).

  • integer. An integer value. Example: 500.

  • float. A floating point number. Example: 3.14.

  • date(posix format). A date or date and time in the specified format. Example: date(%d-%B-%Y).

  • range(lower, upper). The value is a numeric and must be between the upper and lower bounds. Example: range(1,12) - between 1 and 12; range(,50) - there is no lower bound, but the upper value is 50; range(0,) - the minimum value is 0, and there us no maximum value.

  • qr//. A regular expression. Example: qr/!^[A-Z]\d/.