http://qs321.pair.com?node_id=761721


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...