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" };
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";
}
But, that does not work.
I know this works:
foreach my $item (${$hashRef}{list}) {
foreach (@$item) {
print "$_\n";
}
}
But, that seems like a lot of unnecessary work, iteration, and typing. I
would appreciate any help. Thanks in advance! :)
Chris Carver
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]