http://www.perlmonks.org?node_id=11110447


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