fshrewsb has asked for the wisdom of the Perl Monks concerning the following question:
This is very simple, but it happens often and I have to write extra code to handle it :
use Data::Dumper; my $hashref; print Dumper $hashref; if(exists $hashref->{a}->{b}) { # Do something } print Dumper($hashref);
Of course, at the first print $hashref is undef, but after the exists statement $hashref is now: { 'a' => {} } Why ?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: I just want to understand why ...
by Athanasius (Archbishop) on Oct 08, 2012 at 08:18 UTC | |
|
Re: I just want to understand why ...
by 2teez (Vicar) on Oct 08, 2012 at 08:19 UTC | |
|
Re: I just want to understand why ...
by Anonymous Monk on Oct 08, 2012 at 08:35 UTC | |
by Anonymous Monk on Oct 08, 2012 at 08:53 UTC | |
by Athanasius (Archbishop) on Oct 08, 2012 at 09:15 UTC | |
by choroba (Cardinal) on Oct 08, 2012 at 09:17 UTC | |
by Athanasius (Archbishop) on Oct 08, 2012 at 09:24 UTC | |
|
Re: I just want to understand why ...
by parv (Parson) on Oct 09, 2012 at 07:47 UTC | |
by fshrewsb (Acolyte) on Oct 09, 2012 at 10:15 UTC | |
by parv (Parson) on Oct 10, 2012 at 07:17 UTC |