kaka_2 has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks,
I am reading a file and then putting it into an array but resulted array has always 1st line of file missing.
Here is my code
my $file = 'filename.txt'; my @2comp; open (my $fh, '<', $file) or die "cant open : $!"; while(<$fh>) { @2comp = <$fh>; } close $fh; @2comp = sort(@2comp); print "@2comp";
file "filename.txt" has 2 lines but array will show only second. i put more lines in file and i see that always first line of file is missing
What wrong i am doing? -KAKA-
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: reading a file, put into array. Missing first line
by hdb (Monsignor) on Oct 11, 2013 at 16:59 UTC | |
|
Re: reading a file, put into array. Missing first line
by toolic (Bishop) on Oct 11, 2013 at 17:12 UTC | |
by kaka_2 (Sexton) on Oct 11, 2013 at 18:38 UTC | |
|
Re: reading a file, put into array. Missing first line
by exilepanda (Friar) on Oct 12, 2013 at 15:48 UTC |