while(<JOE>) {
@data = <JOE>;
}
each time through the loop, the <JOE> in the while loop reads a line of data into $_. You do nothing with the contents of $_ in the loop, so the first line is effectively lost.
The @data=<JOE> line actually reads ALL remaining lines into the array. When this happens, it causes the next test for the while() to come out false, since there are no more input lines to process.
So, I think all you really want here is to remove the while loop, replacing the above code with:
@data = <JOE>;
For the record, this would also work, and would conceptually be closer to what you were trying to do (but would be less elegant / perl-ish):
while(<JOE>) {
push @data, $_;
}
BTW, your code is very short, next time if it's like that, I suggest you just paste the code into your post rather than link to it. Same with the results. |