Text-AutoCSV

 view release on metacpan or  search on metacpan

scripts/csvcopy.pl  view on Meta::CPAN

warn "$0 not in the same version as Text::AutoCSV"
  if $VERSION ne $Text::AutoCSV::VERSION;

#
# Manage options
#

#
# Each element of @PARAMS is an array ref made of:
#   0: help option as passed to GetOptions
#   1: option type when displaying option value in verbose mode,
#      can be undef (meaning: not applicable), 'STR', 'BOOL' or 'ARRAYREF'
#      ARRAYREF must be followed by the separator
#   2: Text::AutoCSV attribute of option (undef if not applicable)
#   3: option default value (for display only ; *not* passed to Text::AutoCSV
#      attributes)
#   4: help of option, displayed by -h
#   5: (rarely used): enforce passing attribute to Text::AutoCSV even if option
#      is not in use ; used to enforce attributes values for which this script
#      default value does not match Text::AutoCSV default value
my @PARAMS = (
    [ 'help|h',    undef,  undef, undef, 'print a short help screen' ],
    [ 'Help|hh',   undef,  undef, undef, 'print a bigger help screen' ],
    [ 'version|V', 'BOOL', undef, 'no',  'display version and quit' ],
    [ 'verbose|v', 'BOOL', undef, 'no',  'verbose output' ],
    [
        'id', undef, undef, undef,
        'Don\'t copy, instead, print information about input'
    ],
    [ 'i=s', 'STR', 'in_file',  '<stdin>',  'input file (default: stdin)' ],
    [ 'o=s', 'STR', 'out_file', '<stdout>', 'output file (default: stdout)' ],
    [
        'encoding|e=s', 'STR',
        'encoding',     'UTF-8,latin1',
        'encoding (default: auto-detection)'
    ],
    [
        'sep_char|s=s', 'STR', 'sep_char', '<auto-detect>',
        'CSV separator (default: auto-detection)'
    ],
    [
        'quote_char=s', 'STR',
        'quote_char',   '"',
        'CSV quote character (default: ")'
    ],

    [
        'escape_char=s', 'STR', 'escape_char', '<auto-detect>',
        'CSV escape character (default: auto-detection)'
    ],

    [
        'out_encoding=s', 'STR',
        'out_encoding',   '<same as input>',
        'output encoding (default: same as input)'
    ],

    [
        'out_utf8_bom=i', 'BOOL',
        'out_utf8_bom',   'no',
        'add BOM on UTF-8 output (default: no)'
    ],

    [
        'out_sep_char=s', 'STR', 'out_sep_char',
        '<same as input>',
        'output CSV separator (default: same as input)'
    ],

    [
        'out_quote_char=s', 'STR',
        'out_quote_char',   '<same as input>',
        'output quote char (default: same as input)'
    ],

    [
        'out_escape_char=s', 'STR',
        'out_escape_char',   '<same as input>',
        'output escape char (default: same as input)'
    ],

    [
        'out_always_quote=i',
        'BOOL',
        'out_always_quote',
        '<same as input>',
        "always surround each output field with quote chars\n"
          . "0 to remove feature \"always quote\", 1 to enforce it\n"
          . "(default: same as input)"
    ],

    [
        'out_fields=s',
        'ARRAYREF,',
        'out_fields',
        '<same as input>',
        "list of fields to write to output\n"
          . "you separate field names with ','\n"
          . "as in \"NAME,ADDRESS\"\n"
          . "(default: none)"
    ],

    [
        'out_orderby=s',
        'ARRAYREF,',
        'out_orderby',
        '<same as input)>',
        "list of fields to sort output\n"
          . "you separate field names with ','\n"
          . "as in \"NAME,ADDRESS\"\n"
          . "(default: none)"
    ],

    [
        'dont_mess_with_encoding=i',
        'BOOL',
        'dont_mess_with_encoding',
        'no',
        "if set to 1, completely ignore encoding aspects, meaning,\n"
          . "leave it to perl default\n"
          . "(default: input encoding auto-detection)"



( run in 0.890 second using v1.01-cache-2.11-cpan-39bf76dae61 )