如何为CGI脚本的模块设置Perl的包含路径? [英] How can I set Perl's inclusion path for modules for a CGI script?

查看:103
本文介绍了如何为CGI脚本的模块设置Perl的包含路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在主机上的~/perl中安装了几个Perl模块,如何将它们添加到Perl模块路径中?设置PERL5LIBunshift@INC的路径肯定可以,但是当作为CGI脚本运行时,环境变量无济于事,并且@INC方式不是很容易移植.有没有更好的办法?这一定是一个普遍的问题,我有什么遗漏吗?

I’ve got several Perl modules installed on my hosting machine in ~/perl, how do I add them to Perl module path? Setting PERL5LIB or unshifting the paths to @INC surely works, but the environment variable does not help when running as a CGI script and the @INC way is not very portable. Is there a better way? This has to be a common problem, am I missing something?

推荐答案

PERL5LIB适用于CGI脚本.您只需要在正确的位置设置变量,例如服务器配置.您正在使用哪个网络服务器?对于Apache,我使用mod_env中的 SetEnv 指令.

PERL5LIB works just fine for CGI scripts. You just have to set the variable in the right place, such as the server configuration. Which webserver are you using? For Apache, I use the SetEnv directive from mod_env.

@INC是便携式的.您在其中放置的路径可能在每台机器上都不相同,但是变量本身不应该存在问题.

@INC is portable. The paths you put in there may not be the same on every machine, but you shouldn't have a problem the with variable itself.

您是否已阅读 perlfaq8 中的FAQ条目:

Have you read the FAQ entries in perlfaq8:

这篇关于如何为CGI脚本的模块设置Perl的包含路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆