in reply to Re: Perl eats all memory when accessing hash/array refs wrong
in thread Perl eats all memory when accessing hash/array refs wrong
The problem is that you are using a reference as index in an array.
I admit that this appears to be whats going on, But I do not understand how. I see no lookup of an array in that code.
Heres some toying I did with the problem.
#!perl -l use strict; use warnings; my $a = {child1 => [ {child2 => [ {child3 => [ {child4 => [1]} ]} ]} ] +}; print $a->{child1}{child2}{child3}; #cut off {child3} and no problem. print '$a:',ref $a; print '$a->{child1}:',ref $a->{child1}; print '$a->{child1}{child2}:',ref $a->{child1}{child2}; print '@{$a->{child1}}:',scalar @{$a->{child1}}; __END__ $a:HASH $a->{child1}:ARRAY $a->{child1}{child2}:HASH @{$a->{child1}}:28004977
So it would appear that somehow $a->{child1}{child2} is being treated as an array lookup. But how? There is no array lookup involved.
Id be interested to hear an explanation as to why this isnt a bug in perl.
First they ignore you, then they laugh at you, then they fight you, then you win.
-- Gandhi
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Perl eats all memory when accessing hash/array refs wrong
by Anonymous Monk on Sep 25, 2003 at 12:11 UTC | |
by demerphq (Chancellor) on Sep 25, 2003 at 12:22 UTC |