Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Perl "require" question

by stevensw (Acolyte)
on Nov 03, 2012 at 21:12 UTC ( #1002142=perlquestion: print w/ replies, xml ) Need Help??
stevensw has asked for the wisdom of the Perl Monks concerning the following question:

So a script can tell where it's located by the $0 variable right? OK

So what if another script calls "require" on it? Does calling $0 still refer to where it's located? Apparently not, it refers to the script that called require on it. So when that required script tries to call require on other scripts using relative paths, those requires fail if the requiring script is not found in the same directory.

Is there a way to fix this? Thanks

Comment on Perl "require" question
Replies are listed 'Best First'.
Re: Perl "require" question
by choroba (Canon) on Nov 03, 2012 at 21:28 UTC
    Both $0 and $FindBin::Bin in a required module still point to the main programme. __FILE__, on the other hand, does not.
    لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
      That works, many thanks!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (8)
As of 2015-07-29 11:14 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 (263 votes), past polls