ela <
e...@yantai.org> wrote:
>
> use warnings;
You should enable strict on every Perl program:
use strict;
> my ($rankfile) = @ARGV;
> open (FP,$rankfile);
You should always, yes *always*, check the return value from open().
You should use the 3-argument form of open().
You should use a lexical filehandle.
open my $FP, '<', $rankfile or die "could not open '$rankfile' $!";
> my @cells = (); my @AoA = ();
You should declare variables in the smallest possible scope.
Since you do not use @cells outside of the while loop, you should
scope @cells to the while loop's block rather than scoping it
to the whole file like that.
> while ($line=<FP>) { chomp $line; @cells = split /\t/, $line;
while (my $line = <$FP>) {
chomp $line;
my @cells = split /\t/, $line;
> push @AoA, [ @cells ];
Now that @cells is properly scoped, you can take a reference to
it directly rather than having to copy it to an anonymous array:
push @AoA, \@cells;
> }
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.