On Tue, Jun 5, 2012 at 4:15 PM, Chris Stinemetz <chrisstinem...@gmail.com>wrote:

> Why does this short program only seem to capture the last line of
> input in the @array, but when I put the for loop inside the while loop
> all lines of input are available in @array.
>
<snip>

> while ( my $line = <DATA> ) {
>  chomp $line;
>  @array = split(/\s+/, $line,-1);
> }
>

The "while" loop overwrites the contents of "@array". Every line overwrites
the previous one. I believe that you want a two dimensional array here.

-- 
Robert Wohlfarth

Reply via email to