I agree with Alf; it is a bug in Perl's pseudohash support. You happen to have an arrayref of which the first element is a hashref, and that is the definition of a pseudohash. This triggers the same all-you-can-eat memory bug:
my $foo; $foo->[0]->{foo}->{bar} = 'baz'; $foo->{foo}->{foo}->{bar} = 'baz';
As ferrency points out, your examples are confusing. I suspect that something was lost when you trimmed them for posting. Even the first example, which (I think) you meant to be correct, fails on the data you posted. Either $foo needs an additional level of hashref (becoming HoHoH), or the foreach loop is not needed. Also, your return statements should be one level further out in all three examples.
I was working on an example of a less error-prone way to handle your AoHoH, when I realized that something was amiss in the example code. Can you clarify?
In reply to Re: Automagic Array to Hash Conversion? Pseudo-Hash Explosion
by Util
in thread Automagic Array to Hash Conversion? Pseudo-Hash Explosion
by tadman
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |