no autovivification;
is short for
no autovivification qw( fetch exists delete );
However, the list values of the foreach loop is evaluated in lvalue context so the loop body can alter (store values into) the resulting variables.
$_ = uc($_) for @a;
As such, you need
no autovivification qw( fetch exists delete store );
$ perl -e' use Data::Dumper; { no autovivification qw( fetch exists delete ); my $h; for (@{ $h->{k} }) { } print(Dumper($h)); } { no autovivification qw( fetch exists delete store ); my $h; for (@{ $h->{k} }) { } print(Dumper($h)); } ' $VAR1 = { 'k' => [] }; Can't vivify reference at a.pl line 14.
In reply to Re: No autovivification, for loop aliasing, lvalue vs rvalue in for loops
by ikegami
in thread No autovivification, for loop aliasing, lvalue vs rvalue in for loops
by leszekdubiel
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |