Consider these two use cases:
sub test1 {
my $v = 1;
sub test2 { print $v }
# ...
}
and
for (0..3) {
my $foo = $_;
sub test1 { print $foo }
# ...
}
The first one produces a Variable will not stay shared warning, while the second doesn’t. It seems that the variable is not shared in both cases. Why isn’t there any warning in the second case?
It seems that this may be a bug or omission in the
warningspragma.Adding to the fun, this arrangement gives a different warning:
Which warns
Variable "$x" is not availableThese warnings all come from the
pad_findlex()API call defined inpad.c.It seems it has to do with if the containing pad is held within a CV or not, but I am not sure of the exact specifics.