vis1982 has asked for the wisdom of the Perl Monks concerning the following question:
Want to sort the second column with reference/dereference
AA 34
AB 22
AC 12
#!/usr/bin/perl -w print "Please enter the file name: \n"; $file =<STDIN>; chomp $file; unless(open(FILE, $file)) { print "error opening file $file! \n"; exit; } @f=<FILE>; close FILE; $outputfile="sorted_ABA_2.5_nw"; unless(open(ABA, ">$outputfile")) { print "error opening file $outputfile \n"; exit; } foreach $line (@f) { @AB=split("\t", $line); #print "@AB"; #print "$AB[1]", "\t"; #print "$AB[2]"; @AA = sort{$a->[1] <=> $b->[1]} @AB; foreach $temp (@AA) { print "@$temp\t", "\n"; } } close ABA;
The program is not running and output shows the use of uninitalized value <=>.. Any solution..
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: sorting first column
by davido (Cardinal) on Jul 19, 2013 at 06:21 UTC | |
|
Re: sorting first column
by 2teez (Vicar) on Jul 19, 2013 at 06:13 UTC |