in reply to Re: foreach doesn't select array element
in thread foreach doesn't select array element
But shouldn't the foreach() have selected the first array element? If I have a simple array (anna, beth, christie, denise) and pass this @array to foreach, it returns the values. Well, @$fildref3 is a simple array, so when I pass it to foreach(), I expect it to return the members of this array, which is either an array of scalar pairs or the refs to these (in code example 2).
I fail to understand why this doesn't work (simulated dump output):
\@arr = [ 1, 2, 3, [ anna, beth, christie, denise ], ] foreach my girl (@$arr[3]) { print "$girl\n"; }
This is what I try to do. Dump doesn't show:
\@arr = [ 1, 2, 3, \[ anna, beth, christie, denise ], ]
(Note the ref marker in front of the girl array.)
If I understand correctly, the @{} is needed to deref the array ref. But Dump shows me it's an ordinary array, like in my first simple array example in this post.
Thanks for helping out...
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: foreach doesn't select array element
by ELISHEVA (Prior) on May 04, 2009 at 14:37 UTC | |
Re^3: foreach doesn't select array element
by Crackers2 (Parson) on May 04, 2009 at 17:20 UTC | |
Re^3: foreach doesn't select array element
by AnomalousMonk (Archbishop) on May 05, 2009 at 15:15 UTC |
In Section
Seekers of Perl Wisdom