in reply to CSV problem
Update: forget the rest of the post, misread the question. Thanks cbu
You can use split's third argument to limit the number of results to 10.
Look at that short example:
perl -MData::Dumper -wle '$_="a,b,c,,,d,e"; print Dumper [split m/,/, +$_, 3]' $VAR1 = [ 'a', 'b', 'c,,,d,e' ];
Update: you should use while to iterate over your file, because your solution will first slurp all of the file into memory, which is slow.
open (OUT, ">", "file.csv" or die "Can't read file.csv: $!"; while (my $line = <OUT>){ chomp $line; my @records = split m/,/, $line, 10; # do your work here }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: CSV problem
by Tux (Canon) on Mar 07, 2008 at 16:41 UTC |