Hi,

You wrote on 03/30/2009 04:07 PM:
> How can I retrieve data loaded into an array within a foreach block?
> The array is defined outside the foreach block and is not the indexing
> array of the foreach loop.

I ran your code and it works fine here.
I did however have the same problem as you at first, so maybe you made
the same mistake I did at first.

> foreach (@lines) {
>       @line = split /\t/, $_;
>       push @lastnames, $line[2];
> }

Are you sure that the split (always) produces an array with three
elements? In my test array it only had two a la "alex\tkoenig", which
resulted in the error messages you described.

To test this you could insert a print line after the split. Something
like this.

print "$line[0]\t$line[1]\t$line[2]\n";

bye
Alex

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to