in reply to Re: dynamically expand @INC beyond BEGIN
in thread dynamically expand @INC beyond BEGIN

both $lib and $module are variables. use does not work with $vars in any way afaik.
  • Comment on Re^2: dynamically expand @INC beyond BEGIN

Replies are listed 'Best First'.
Re^3: dynamically expand @INC beyond BEGIN
by tobyink (Canon) on Apr 17, 2012 at 22:02 UTC
    # Here's a variable... my $lib; # Make sure it gets defined at compile-time... BEGIN { $lib = '/foo' } # Use the variable in a "use" line... use lib $lib; # Check that it worked... use Data::Dumper; print Dumper \@INC;

    ... And lo and behold, it has worked!

    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'