in reply to ADD directory to @INC using a string variable

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

  • Comment on Re: ADD directory to @INC using a string variable (not when variables initialized use BEGIN)
  • Download Code

Replies are listed 'Best First'.
Re^2: ADD directory to @INC using a string variable (not when variables initialized use BEGIN)
by sid9559 (Novice) on Sep 23, 2013 at 15:45 UTC
    Thanks for the resources and links. I will take a look at them and see if I can make it work. Regards, Siddharth