develooper Front page | perl.perl5.porters | Postings from March 2016

[perl #127712] defined on HashofHash defines an element in the hash

Thread Previous | Thread Next
From:
James E Keenan via RT
Date:
March 14, 2016 22:40
Subject:
[perl #127712] defined on HashofHash defines an element in the hash
Message ID:
rt-4.0.18-14858-1457995211-1644.127712-15-0@perl.org
On Mon Mar 14 15:36:44 2016, jkeenan wrote:
> On Mon Mar 14 09:45:35 2016, phberninger@gmx.net wrote:
> > Checking with defined for an Hash of Hash element defines the element
> > in the
> > hash, instead of returning undefined:The following code will
> > reproduce
> > it: perl
> > -e 'if(defined($foo{"a"}{"b"})){ print "not
> > defined\n";}if(defined($foo{"a"})){
> > print "ERROR? now defined?\n";} ' I hope it is not a feature. tested
> > with perl
> > 5.20.2 under Linux
> 
> I do not believe this is a bug.
> 
> The test for definedness of $foo{a}{b} in the first 'if' block
> autovivifies $foo{a},

That post was incomplete.  See attached.

-- 
James E Keenan (jkeenan@cpan.org)

---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=127712

Thread Previous | Thread Next


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