sectokia has asked for the wisdom of the Perl Monks concerning the following question:
I thought I knew perl, and then this tripped me up:
result:use Data::Dumper qw(Dumper); my $a = { b => {} }; my $f = $a->{b}{c}{d}//undef; print Dumper $a
$VAR1 = { 'b' => { 'c' => {} } };
Why does 'c' key get created during what is meant to be only an assignment operation? And under that logic, why isn't 'd' made a key of 'c' with value undef?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Arrow Operator Question
by swl (Prior) on Mar 26, 2023 at 09:17 UTC | |
Re: Arrow Operator Question
by kcott (Archbishop) on Mar 26, 2023 at 11:45 UTC | |
by BillKSmith (Monsignor) on Mar 27, 2023 at 14:24 UTC | |
by hv (Prior) on Mar 27, 2023 at 17:28 UTC | |
by BillKSmith (Monsignor) on Mar 28, 2023 at 18:07 UTC | |
by kcott (Archbishop) on Mar 27, 2023 at 16:57 UTC | |
by BillKSmith (Monsignor) on Mar 28, 2023 at 18:02 UTC | |
by sectokia (Friar) on Mar 27, 2023 at 08:41 UTC | |
by kcott (Archbishop) on Mar 27, 2023 at 10:14 UTC | |
Re: Arrow Operator Question
by tobyink (Canon) on Mar 26, 2023 at 11:54 UTC | |
Re: Arrow Operator Question (Autovivification motivated)
by LanX (Saint) on Mar 26, 2023 at 13:12 UTC |