Beefy Boxes and Bandwidth Generously Provided by pair Networks RobOMonk
There's more than one way to do things
 
PerlMonks  

Re: how to include a directory in @INC?

by mikfire (Deacon)
on Mar 03, 2000 at 02:07 UTC ( [id://4731]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to how to include a directory in @INC?

Assuming you are on a UNIX boxen, and you have sufficient ( ie, root-like ) powers, there is on evil solution. I am uncertain of the security implications, so you may really want to think twice before doing this for your webserver.

For every directory you wish to "permanently" add to @INC, create a symlink from the directory in your perl's site_perl ( eg, /usr/local/lib/perl5/site_perl ). Perl will cross the symlink when searching the paths.

This suggestion is expected to be taken at your own risk. DO NOT blame me if somebody figured out how to exploit this from your webserver.

Mik Mik Firestone ( perlus bigotus maximus )

  • Comment on Re: how to include a directory in @INC?

Replies are listed 'Best First'.
•Re: Re: how to include a directory in @INC?
by merlyn (Sage) on Jul 03, 2002 at 11:59 UTC
    That works for only one other directory. Perl doesn't recurse to find an entry that is not directly an element of @INC. All you're doing is moving one of the elements of @INC to a specific different space.

    To be specific, suppose I symlink the/home/merlyn/private directory into my site_lib I can't just add MyModule.pm into that directory and call it with everyone's use MyModule. They'd have to say use private::MyModule. The path is affected. It's not recursive, it's a flat search based on the content of @INC followed by the filename derived from the module name.

    Now, you could effectively copy every entry that you want directly into the site_lib dir (like putting MyModule.pm directly there). But that's not changing @INC, nor making it more flexible. The only way to do this is to recompile Perl, and we're back to the same old solution.

    So, no, this is not "dirty", because it's not even a solution.

    -- Randal L. Schwartz, Perl hacker

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://4731]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.