in reply to Automagic Array to Hash Conversion? Pseudo-Hash Explosion
my $foo = [ { foo => { bar => 'baz' } }, ]; foreach my $foo_entry (@$foo) { foreach (keys %$foo_entry) { if (defined($foo_entry->{$_}->{foo}) && defined($foo_entry->{$_}->{foo}->{bar})) { return $foo_entry->{$_}->{foo}->{bar} +; } } return; }
In the inner loop, $_ is a key of %$foo_entry. I'm not sure why your code passes strict, since $foo should contain an array ref and not a hash ref; I'd expect the if statement to bomb with "not a hashref".
I'm also confused about your question: Do you know the answer, and you're testing us, or have you still not figured out what's wrong?
Thanks :)
Update: On FreeBSD, perl 5.6.0, I get:
% perl hoh.pl Out of memory during "large" request for 1073745920 bytes at hoh.pl line 15.
Alan
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Automagic Array to Hash Conversion? Pseudo-Hash Explosion
by tadman (Prior) on May 14, 2002 at 18:33 UTC |