Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^2: Developing CGI::Application based modules outside of the default @INC

by DBX (Pilgrim)
on Apr 10, 2008 at 18:56 UTC ( [id://679556]=note: print w/replies, xml ) Need Help??


in reply to Re: Developing CGI::Application based modules outside of the default @INC
in thread Developing CGI::Application based modules outside of the default @INC

Actually if you are on a linux/unix platform, I would strongly recommend getting your @INC path from $ENV{PERL5LIB}. This way you never have to change your code and you can change libraries from development or testing or production or anywhere else simply by changing the environment variable. This works equally well for CGI based applications as it does for CLI.
  • Comment on Re^2: Developing CGI::Application based modules outside of the default @INC

Replies are listed 'Best First'.
Re^3: Developing CGI::Application based modules outside of the default @INC
by spacebat (Beadle) on Apr 12, 2008 at 22:03 UTC
    This works equally well for CGI based applications as it does for CLI.

    Not quite true. Public CGI should use taint mode (as does the code in the original post), which means the environment is untrusted and PERL5LIB has no effect. Environment variables not set by CGI input should be trustworthy though.

    Taint::Runtime can get around this, as can something like this at the start of your script:

    BEGIN { if ($ENV{PERL5LIB} && $ENV{PERL5LIB} =~ /^(.*)$/) { eval "use lib (".join(',', map "'$_'", split ':', $1).");"; die $@ if $@; } }
    (updated to fix a typo)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://679556]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-04-19 02:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found