Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Set include path

by jayto (Acolyte)
on Aug 06, 2012 at 13:33 UTC ( #985710=perlquestion: print w/ replies, xml ) Need Help??
jayto has asked for the wisdom of the Perl Monks concerning the following question:

So I have a folder called patchManagement. In that folder I have a lib folder. I want to run a perl file from the patchManagement folder that uses the modules in the lib folder, I tried using use lib '/lib' and use lib '$FindBin::Bin/lib' I am obviously doing this wrong, how should I be doing it?


Here are my errors incase they help.

Can't locate ID/PatchAssembly/ICSCERT.pm in @INC (@INC contains: /usr/ +local/lib/perl5 /usr/local/share/perl5 /usr/lib/perl5/vendor_perl /us +r/share/perl5/vendor_perl /usr/lib/perl5 /usr/share/perl5 .) at test. +pl line 4. BEGIN failed--compilation aborted at test.pl line 4.

the ID folder is inside the lib folder

Comment on Set include path
Select or Download Code
Re: Set include path
by MidLifeXis (Prior) on Aug 06, 2012 at 13:35 UTC
      Those docs are what I followed to get my above attempts.

        The first: use lib '/lib' will attempt to find your library file in the root of the current drive. If you mean that it should look in the lib directory under the current directory, then use lib 'lib' would be appropriate, although potentially risky 1.

        moritz has addressed the usage issue with your other attempt.

        1 - Given that any attacker could probably copy your script anyway, I am having a hard time adding any additional risk by a user being able to replace your library with one that they 'own', therefore the use of 'potentially'.

        --MidLifeXis

            Those docs are what I followed to get my above attempts.

        OK: show us your code then. In the last 24 years I've used various flavors of use lib .. and push @INC,"..." with success. The only time either hasn't worked for me is when I fat fingered something (like a path).


        Peter L. Berghold -- Unix Professional
        Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg
Re: Set include path
by moritz (Cardinal) on Aug 06, 2012 at 13:42 UTC
      tried that, no luck :/

        What is the error message when you "try that"?

        Fixed, I was putting the use lib after the includes for the other modules that couldn't be found.
Re: Set include path
by Anonymous Monk on Aug 06, 2012 at 20:08 UTC
    The use lib statement is effectively executable, not a declaration, therefore it should be put first.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://985710]
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (12)
As of 2014-07-24 20:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (166 votes), past polls