Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Lib path declaration

by santhosh_89 (Scribe)
on Oct 28, 2009 at 05:59 UTC ( #803587=perlquestion: print w/ replies, xml ) Need Help??
santhosh_89 has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks

I have downloaded a cpan module called Config::Abstract::Ini,It is available in my home directory and /usr/lib also.Default the @INC will have the /usr/lib path.But I want to take and use my home directory module.The path will be given from global values.If the values is empty,it should take default path(/usr/lib).If the home directory path is error,it should say an error.

if($path ne ''){ unshift(@INC,"$path"); } use Config::Abstract::Ini;

NOTE: I used above code it is searching from default directory.even I would give wrong path in global value.

Comment on Lib path declaration
Download Code
Re: Lib path declaration
by Anonymous Monk on Oct 28, 2009 at 06:16 UTC
Re: Lib path declaration
by GrandFather (Sage) on Oct 28, 2009 at 06:19 UTC

    use is compiled before other normal code. You have either to use require or edit the include path in a BEGIN block before the use:

    use strict; use warnings; BEGIN { if ($path ne ''){ unshift @INC, $path; } } use Config::Abstract::Ini;

    Note that $path must be set (probably in a previous BEGIN block) before being used as shown above.


    True laziness is hard work

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2015-07-04 16:13 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 (60 votes), past polls