in reply to Parsing/manipulating CSV files
Stick that in a loop as you iterate over your file:my ($addr,$state,$pc) = $line =~ /([^,]+),([^,]+),([^,]+)/;
Now you can do what you like with the post codes. Note that this doesn't read the whole file in one go - but 1 line at time.open DATA , "<", "path-to-file"; my @pcodes; while (my $line = <DATA>){ my ($addr,$state,$pc) = $line =~ /([^,]+),([^,]+),([^,]+)/; ## Not a valid data line? Then move on. defined $pc or next; push @pcodes, $pc; } ## Do stuff with @pcodes close DATA;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Parsing/manipulating CSV files
by Ansi (Initiate) on Oct 21, 2011 at 18:07 UTC | |
by mrstlee (Beadle) on Oct 22, 2011 at 12:32 UTC |