in reply to Re^3: Array dereference in foreach()
in thread Array dereference in foreach()
Hi haukex,
Thank you to for your detailed explanation. That makes sense. However I found another interesting feature.
and the output ismy $h; my $g; $h->{abc} = $g->{lkj}; print "h: ", Dumper(\$h), "\n"; print "g: ", Dumper(\$g), "\n";
The left side ($h) is autovivified and undef is assigned to key 'abc'. It is correct. But what has happened on the right? Is it semi-autovivified or what? Empty anonymous hashref is assigned to $g. Where is 'lkj'? Is $g->{lkj} in lvalue context? Why there is no exception?h: $VAR1 = \{ 'abc' => undef }; g: $VAR1 = \{};
Regards
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^5: Array dereference in foreach()
by choroba (Cardinal) on Nov 16, 2017 at 10:20 UTC | |
by pme (Monsignor) on Nov 16, 2017 at 12:17 UTC | |
by choroba (Cardinal) on Nov 16, 2017 at 12:23 UTC | |
by pme (Monsignor) on Nov 16, 2017 at 12:55 UTC | |
by choroba (Cardinal) on Nov 16, 2017 at 12:59 UTC | |
| |
by haukex (Archbishop) on Nov 16, 2017 at 12:43 UTC | |
Re^5: Array dereference in foreach()
by 1nickt (Canon) on Nov 16, 2017 at 12:19 UTC |
In Section
Seekers of Perl Wisdom