in reply to Re: dynamically loading modules/maintaining dev v. prod modules
in thread dynamically loading modules/maintaining dev v. prod modules

This sounds interesting if a little obfu-ish. Sadly I can not get a sub put on @INC to execute

> perl -mlib="sub{\$x=10}" -le'BEGIN{print "x=",$x++};\ use FindBin;\ print "x=$x"; print join $/,@INC' x=0 x=1 sub{$x=10} /local/lib/perl /usr/local/lib/perl5 /usr/opt/perl5/lib/5.8.0/aix-thread-multi /usr/opt/perl5/lib/5.8.0 /usr/opt/perl5/lib/site_perl/5.8.0/aix-thread-multi /usr/opt/perl5/lib/site_perl/5.8.0 /usr/opt/perl5/lib/site_perl .
I expected to see x=10 after the use FindBin had run down the @INC path. What do I miss ?

Cheers,
R.

Pereant, qui ante nos nostra dixerunt!

Replies are listed 'Best First'.
Re^3: dynamically loading modules/maintaining dev v. prod modules
by John M. Dlugosz (Monsignor) on Jun 01, 2006 at 19:26 UTC
    You added a string to the list. The string happened to contain Perl syntax rather than a directory name.

    You have to use a ref to a sub, not a string to be evaled.

    sub x { print "I'm here! [@_]\n" }; use lib \&x; use FindBin; print "done.\n";
    —John

      Nice trick, thanks for the help.

      Cheers,
      R.

      Pereant, qui ante nos nostra dixerunt!