in reply to Re: unexpected modify hash in a distance with grep { $_ }
in thread unexpected modify hash in a distance with grep { $_ }
It seems to be a general issue that accessing an alias is sometimes triggering autovivification.
Didn't know that. Smells like bug.
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my $h = { 'a' => 1, 'b' => 2, 'c' => 3, }; warn "x: ",$_ for $$h{x}; # autovivifiaction via alias warn Dumper [ keys %$h ]; tst($$h{y}); # no autovivification warn Dumper [ keys %$h ]; sub tst { warn "y: ",$_[0] ; }
C:/Perl_524/bin\perl.exe d:/tmp/pm/grep_autovivify.pl Use of uninitialized value $_ in warn at d:/tmp/pm/grep_autovivify.pl +line 13. x: at d:/tmp/pm/grep_autovivify.pl line 13. $VAR1 = [ 'c', 'x', 'b', 'a' ]; Use of uninitialized value $_[0] in warn at d:/tmp/pm/grep_autovivify. +pl line 24. y: at d:/tmp/pm/grep_autovivify.pl line 24. $VAR1 = [ 'c', 'x', 'b', 'a' ];
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
FootballPerl is like chess, only without the dice
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: unexpected modify hash in a distance with grep { $_ } (inconsistent behaviour of aliasing)
by dave_the_m (Monsignor) on Dec 20, 2019 at 22:38 UTC | |
by LanX (Saint) on Dec 20, 2019 at 22:57 UTC | |
by dave_the_m (Monsignor) on Dec 21, 2019 at 00:01 UTC | |
by LanX (Saint) on Dec 21, 2019 at 18:50 UTC | |
by Anonymous Monk on Dec 21, 2019 at 16:42 UTC | |
by Anonymous Monk on Dec 21, 2019 at 20:23 UTC |
In Section
Seekers of Perl Wisdom