Text::CSV::Euclid - Provide a csv parser with options specified on the command-line
In your script:
use Text::CSV::Euclid; my $csv = Text::CSV::Euclid->csv; # Now do interesting stuff that involves parsing CSV. parse_CSV_files_using($csv);
Now, to run your script:
$ perl your-script.pl --sep-char='|' --quote-char="'" --escape-char"'"
Your script will read CSV files with vertical bars as separators and single quotes as quotation characters, instead of the defaults (which are commas and double quotes).
$ perl your-script.pl --sep-char='\t' --quote-char="=" --escape-char"="
Your script will read CSV files with tabs characters as separators and equals signs as quotation characters.
All the options to Text::CSV->new should be supported. These are listed in the OPTIONS section.
This module is intended to be used from a script that deals with tabular data in files. Using this module will allow the user of your script to specify all possible options to Text::CSV's constructor by passing command-line arguments to your script.
This function returns the CSV object created according to the command-line arguments that were passed to the script. Note that this object is only created at the time of its first access, and not before. This means that your script may change elements of
%ARGV as it wishes before calling
csv, and the returned CSV object will use the modified options. In particular, you can change the defaults in your script without using a BEGIN block.
The following command-line arguments all correspond to the arguments to Text::CSV->new:
- --quote-char [=] <char>
- --escape-char [=] <char>
- --sep-char [=] <char>
- --eol [=] <eol>
Error: unable to create csv parser object before options have been parsed.
You tried to use the csv method of this module before the program's command-line options were parsed. Since the options were not parsed, the module could not know what options to use to construct a CSV object for you. This error is probably only possible if you suppress the import method of this module by using it with an empty import list.
- Other errors
See Getopt::Euclid and Text::CSV for errors that could possibly be generated by command-lline parsing or CSV object usage, respectively.
This module uses Getopt::Euclid, so it may not interact well with other modules from the Getopt:: family.
No bugs have been reported.
Please report any bugs or feature requests to
See perlmodinstall for information and options on installing Perl modules.
Ryan C. Thompson <firstname.lastname@example.org>
This software is copyright (c) 2010 by Ryan C. Thompson.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.