in reply to indefinite number of columns
Why not just parse each workbook of the spreadsheet using Spreadsheet::ParseExcel? The first example shows how to do this. Modifying this example to work on a per column basis (rather than by row) would be trivial.
Update: My mistake, you're working with a csv file.
book.csv:
1,2 ,3 1,2, 3 1,2,43 1 12,1 apple, 1, 3 orange 7,onion, 8, 9
Sample code using Text::CSV:
#!/usr/bin/perl use strict; use warnings; use Text::CSV; use Data::Dumper; my $csv = Text::CSV->new({ sep_char => ',' }); my $file = "book.csv"; open(my $csvdata, '<', $file) or die "Could not open '$file' $!\n"; while (my $line = <$csvdata>) { chomp $line; if ($csv->parse($line)) { my @fields = $csv->fields(); print Dumper \@fields; } }
What exactly are you trying to achieve?
|
|---|