1) don't do that, 2) don't do that 3) Read Tutorials: Variable Scoping in Perl: the basics, Coping with Scoping 4) Read Re: Recommendation for dynamically "using" modules (export import into) 5) Read PERL5LIB, PERL5OPT , Re^2: How do I tell CPAN to use a local lib? (perllib/perl5lib/perl5opt/-Idirectory/-Mblib/sitecustomize.pl ) 6) File::FindLib,FindBin, %ENV
$ perl -E " $foo = 1; my $bar = 2; BEGIN{ say -WHAT,$foo,$bar; } say $ +foo,$bar; " -WHAT 12 $ perl -wE " $foo = 1; my $bar = 2; BEGIN{ say -WHAT,$foo,$bar; } say +$foo,$bar; " Use of uninitialized value $foo in say at -e line 1. Use of uninitialized value $bar in say at -e line 1. -WHAT 12 $ perl -wE " my $bar; BEGIN{$foo = 1; $bar = 2;} BEGIN{ say -WHAT,$foo +,$bar; } say $foo,$bar; " -WHAT12 12
use happens at BEGIN time, lexicals(my variables) have no value at BEGIN time, lexicals(my) get initialized after BEGIN
But like I said, don't do that
In reply to Re: ADD directory to @INC using a string variable (not when variables initialized use BEGIN)
by Anonymous Monk
in thread ADD directory to @INC using a string variable
by sid9559
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |