Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re: use lib in cgi env

by sundialsvc4 (Abbot)
on Nov 05, 2012 at 15:08 UTC ( #1002338=note: print w/replies, xml ) Need Help??

in reply to use lib in cgi env

In a recent (FastCGI) application main-script, I once did this:

BEGIN { if (-f '/opt/location1/') { ## production environment: unshift( @INC, '/opt/location1/lib', '/opt/location1/scripts' ); } else { ## dev environment: unshift( @INC, '/opt/location2/lib', '/opt/location2/scripts', '/opt/location3/debug_lib' ); } }

The BEGIN block’s contents are executed before compilation begins, and therefore can be used to determine things such as library locations.   This example used the existence of a particular file in a particular location to decide where the libraries would be.   The use lib nomenclature was not used.

Developers relied upon setting the PERL5LIB environment variable to establish the library-location (appropriate to their particular machines), as the above mechanism would not have been invoked as they wrote and tested their code.

I’m not saying that this is the only way nor necessarily the best one.   But, it did work.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1002338]
[stevieb]: one of my long-running Perl procs crashes with a segfault (because it wraps C code) is crashing after an hour or so... seeing if wrapping the cli call with valgrind will produce something useful

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (3)
As of 2017-04-29 03:12 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (531 votes). Check out past polls.