... prints "ARRAY". But if for some reason you're testing the stringification of an array reference (not the return value of ref), then you shouldn't use eq.perl -le '$foo{"bar"} = ["a","b"]; print ref $foo{"bar"}'
What are you expecting to see in your output? Hashes are not interpolated into strings, but arrays are, so printing "Array in Array item: @$item" should print the array elements in $item. A clearer way would be a foreach loop or map, perhaps like this:
if (ref $item eq 'ARRAY') { print "Array in Array item:\n"; foreach (@$item) { print " $_\n"; } } elsif (ref $item eq 'HASH') { print "Hash in Array item:\n"; foreach (keys %$item) { print " $_ -> $item->{$_}\n"; } } else { print "Array Item: $item\n"; }
-- Mike
--
just,my${.02}
In reply to Re: Re: Re: A hash of an array containing hashes & arrays
by thelenm
in thread A hash of an array containing hashes & arrays
by ebodine
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |