Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

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]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2018-05-22 21:51 GMT
Find Nodes?
    Voting Booth?