[EMAIL PROTECTED] wrote: > Hello, > > I'm having trouble grasping the syntax to perform foreach operation on an > anonymous array within an anonymous hash reference. > > my $hashRef = { bah => "humbug", > list => [ "lions", "tigers", "bears", "oh_my" ], > woo => "hoo" };
here you have a hash ref named $hashRef > > How can I run a foreach on every item in that anonymous array reference > that > is a value of the key "list" in the hash reference? I'm having great > difficulties getting this to work. Is it even possible without nested > foreach > structures? I would think it would be something like: > > foreach my $listItem (@{$hashref{list}}) { > print "$_list item is one item of the array! Woo hoo!\n"; > } here you are trying to access the 'list' slot of a hash named $hashref which on course is different than $hashRef you declared above. not to mention that you are not treating $hashref as hash reference, you are using it as a hash. which one is it? is $hashref really a hash reference or just a hash? is $hashRef the same as $hashref? if $hashref is the same as $hashRef and it's really a hash reference, try: for(@{$hashRef->{list}}){ print "$_\n"; } if $hashref is NOT the same as $hashRef and it's really just a hash, you have the right syntax: for(@{$hashref{list}}){ print "$_\n"; } david -- $_=q,015001450154015401570040016701570162015401440041,,*,=*|=*_,split+local$"; map{~$_&1&&{$,<<=1,[EMAIL PROTECTED]||3])=>~}}0..s~.~~g-1;*_=*#, goto=>print+eval -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]