Thank you for that example. When edited as shown below, it clearly highlighted the differences:
use warnings;
use v5.14;
outer1();
exit 0;
sub outer1 {
my $hello = 'hello';
# local *inner = sub {
my $inner = sub {
say $hello;
};
outer2();
}
sub outer2 {
# inner();
$inner->();
}
__END__
Global symbol "$inner" requires explicit package name at /tmp/subtst.p
+l line 20.
Execution of /tmp/subtst.pl aborted due to compilation errors.
Compared with your example, we can show the more limited scope of the lexical form, as recommended by Laurent_R. Thank you both!