in reply to sorting CSV files
TMTOWTDI ... but an array of arrays would work:
#!/usr/bin/perl my $sheet; my $count = -1; while( <DATA> ) { chomp; $count++; # skip header next unless $count; my $row; @$row = split( /,/, $_ ); push @$sheet, $row; } foreach my $row ( sort { $a->[1] <=> $b->[1] } @$sheet ) { print join( ',', @$row ), "\n"; } __DATA__ Name,Score,State Mike,67,CA Rob,63,FL Jim,72,IL Chan,32,AZ
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: sorting CSV files
by argupta (Initiate) on Feb 05, 2009 at 22:43 UTC | |
by derby (Abbot) on Feb 05, 2009 at 23:12 UTC |