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


in reply to Scope in use

I don't see how the current behavior could possibly be called "good." The scope of a my variable doesn't start until the end of the statement it appears in...

>perl -wle 'print($x, (my $x = 42), $x);print "now $x"' Use of uninitialized value $x in print at -e line 1. Use of uninitialized value $x in print at -e line 1. 42 now 42

... so AFAICT there's no way to refer to a lexical created in a use statement at all.

But why would you write
use lib my $lib = '.';
in the first place? Probably because this doesn't work:
my $lib = '.';
use lib $lib;
This seems to be a common problem that people run into. Should we tell them to write this instead?
my $lib = '.';
unshift @INC, $lib;
Or maybe this?
BEGIN { our $lib = '.' }
use lib our $lib;
IDK, but IMO that's the real issue.