develooper Front page | perl.perl5.porters | Postings from February 2000

Re: bad pseudo-hash, missing warning?

Thread Previous
From:
Ilya Zakharevich
Date:
February 28, 2000 14:04
Subject:
Re: bad pseudo-hash, missing warning?
Message ID:
200002282204.RAA06028@monk.mps.ohio-state.edu
Pixel writes:
> 
> Something like:
> 
> use strict;
> $a = [ { a => { any => 111 } } ];
> print values %$a;
> 
> ends with "Out of memory!" (on linux, both 5.5.660 and 5.005_03)
> 
> this happened because of an programming error (thinking $a was an hash ref whereas
> it was an array ref (array of hashes))

This is almost normal.  Can anybody see a reasonable way to catch

 $a = [ { a => 2e8 } ];
 $a->{a} = 1;

?  On the other hand,

 print $a->{a}

does not allocate all this memory, so probably

 print values %$a

should not as well?

Ilya

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About