Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^3: use lib $lib_dir not working

by bart (Canon)
on Apr 27, 2011 at 10:30 UTC ( [id://901520]=note: print w/replies, xml ) Need Help??


in reply to Re^2: use lib $lib_dir not working
in thread use lib $lib_dir not working

No; guess again.

The problem is with @dirs. Did you assign it in the BEGIN block? If you declare it with "my", make sure you do that in outside the BEGIN block. the actual use line should also be outside (after) that block. And is $0 actually the full path? I think perhaps your @dirs array is just too short for the splice. You might have to use rel2abs to make it so.

Anyway, I would do it another way, and put the code in a do block. Untested:

use File::Spec::Functions qw(rel2abs) use lib do { my @dirs = split('/', rel2abs($0)); splice(@dirs,-2); my $install_dir = join('/',@dirs); $install_dir."/lib" };

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-04-25 14:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found