Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^2: dynamically loading modules/maintaining dev v. prod modules

by Random_Walk (Parson)
on May 29, 2006 at 11:26 UTC ( #552287=note: print w/ replies, xml ) Need Help??


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!


Comment on Re^2: dynamically loading modules/maintaining dev v. prod modules
Download Code
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!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://552287]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2015-07-03 22:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (57 votes), past polls