in reply to Automagic Array to Hash Conversion? Pseudo-Hash Explosion
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?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Automagic Array to Hash Conversion? Pseudo-Hash Explosion
by tadman (Prior) on May 14, 2002 at 20:04 UTC |