Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
... my $csv = Text::CSV_XS->new(); open (CSV, "<", $file_to_parse) or die "Could not open '$file' $!<b +r>"; while (my $line = <CSV>) { chomp $line; if ($csv->parse($line)) { my @columns = $csv->fields(); #check user file format been uploaded TEST: perl -le 'pr +int "1234567" =~ /^[[:alnum:]]+$/ ? "OK" : "BAD"' if( ($columns[0]!~/^[[:alnum:]]+$/) && ($columns[2]!~/^[ +[:alnum:]]+$/) ) { # wrong format exit; }else{ my $err = $csv->error_input; print "<br><b>Failed to parse line, please call for help +!</b><br>"; } } ...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: CSV File Parsing
by Tux (Canon) on Feb 28, 2013 at 20:55 UTC | |
|
Re: CSV File Parsing
by Not_a_Number (Prior) on Feb 28, 2013 at 19:08 UTC | |
|
Re: CSV File Parsing
by Generoso (Prior) on Mar 01, 2013 at 02:54 UTC | |
|
Re: CSV File Parsing
by stephen (Priest) on Feb 28, 2013 at 19:05 UTC | |
|
Re: CSV File Parsing
by blue_cowdawg (Monsignor) on Feb 28, 2013 at 18:57 UTC | |
by Anonymous Monk on Feb 28, 2013 at 19:43 UTC |