Steve_BZ has asked for the wisdom of the Perl Monks concerning the following question:
Hi Guys,
Why does a Perl expression acting on an empty nested hash element create parents for the element eg:
#!/usr/bin/perl -w use strict; use warnings; my %a; my $a = scalar keys %{a}; print $a,"\n"; if (not exists $a{a}{a}{a}){ $a = scalar keys %{a}; print $a,"\n"; } print "End\n";
prints:
0 1 End
not
0 0 End
And is the only way to avoid this, to check the higher levels of the hash first?
Regards
Steve
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Why does perl expression in empty nested hash create parents
by Eliya (Vicar) on Feb 21, 2011 at 19:19 UTC | |
Re: Why does perl expression in empty nested hash create parents
by bellaire (Hermit) on Feb 21, 2011 at 19:21 UTC | |
Re: Why does perl expression in empty nested hash create parents
by ikegami (Patriarch) on Feb 21, 2011 at 19:25 UTC | |
Re: Why does perl expression in empty nested hash create parents
by furry_marmot (Pilgrim) on Feb 21, 2011 at 19:23 UTC | |
Re: Why does perl expression in empty nested hash create parents
by Steve_BZ (Chaplain) on Feb 21, 2011 at 19:28 UTC | |
by Anonymous Monk on Feb 22, 2011 at 03:17 UTC | |
Re: Why does perl expression in empty nested hash create parents
by mellon85 (Monk) on Feb 21, 2011 at 19:18 UTC | |
Re: Why does perl expression in empty nested hash create parents
by sundialsvc4 (Abbot) on Feb 22, 2011 at 15:29 UTC |
Back to
Seekers of Perl Wisdom