Hi,
I'm trying to sort sort a multiple columns flat file converted to arrays but I must be doing something wrong. (stupid error)
See my data structure (file) and code below:
I'm trying to sort sort a multiple columns flat file converted to arrays but I must be doing something wrong. (stupid error)
See my data structure (file) and code below:
Code:
ID|NAME|ADDRESS|SOMETHING|
11|Ben|223 Long Street|Some Data
Code:
open(TBL,"$Filename") || die("Can't open flat file");
my $ColumnNames = <TBL>;
my @Table = <TBL>;
close(TBL);
foreach my $record (sort { $a->[1] cmp $b->[1] } @Table) {
chomp $record;
my @Field=split(/\|/,$record);
if ($Field[1] ne 0) {
print qq ( $Field[1] \n );
}
}