Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Conditional 'use lib'

by Chmrr (Vicar)
on Feb 26, 2003 at 08:04 UTC ( #238701=note: print w/ replies, xml ) Need Help??


in reply to Conditional 'use lib'

The work is done inside of lib.pm's import method, so you might try:

BEGIN { use Sys::Hostname; require lib; if (hostname() eq 'foo.bar.org') { lib->import('/alternate/libdir'); } else { lib->import('/default/libdir'); } }

The advantage of this over the unshift trick is that you'll get architecture-dependent paths added, as well.

perl -pe '"I lo*`+$^X$\"$]!$/"=~m%(.*)%s;$_=$1;y^`+*^e v^#$&V"+@( NO CARRIER'


Comment on Re: Conditional 'use lib'
Download Code
Replies are listed 'Best First'.
Re^2: Conditional 'use lib'
by Anonymous Monk on Dec 04, 2007 at 18:48 UTC
    Just found an even easier way, which seems to work for me: my $module = "ROX::Filer"; eval "use $module"; die "couldn't load $module : $!n" if ($@); See http://weierophinney.net/matthew/archives/23-conditional-use-in-perl.html

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (10)
As of 2015-07-29 21:33 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 (269 votes), past polls