Today I was surprised when I came across the following behaviour in perl:
sub f { die if %{ $_[0] }; 42 }
my %h;
$h{x} ||= f(\%h); # we die. $_[0] references a hash with an 'x' key during f's run-time
In contrast, given the same set-up, the following statement behaves differently.
$h{x} = $h{x} || f(\%h); # $h{x} is now 42
Is this potential difference between assign-or and the combination of assignment and logical-or documented somewhere?
If this is due to auto-vivification, is it a bug or missing feature in the autovivification module which doesn't seem to be able to detect auto-vivification in this particular construct?