gpt4 book ai didi

Perl:将当前目录包含到@INC?

转载 作者:行者123 更新时间:2023-12-02 07:58:14 25 4
gpt4 key购买 nike

我正在将一些网站从旧网络服务器迁移到新网络服务器。旧的网络服务器使用 Perl 5.8,新的网络服务器使用 Perl 5.28。两者之间的区别之一是在 5.8 上,脚本运行的目录默认包含在 @INC 中。 5.28 并非如此。这意味着“需要”本地文件的 cgi 脚本会抛出错误。

我知道我可以将这些行添加到脚本中来解决问题:

use FindBin qw( $RealBin );
use lib $RealBin;

但问题在于,我需要为很多脚本执行此操作。

有没有办法一次性将所有脚本的当前目录 (.) 添加到 @INC?最好仅供 www 数据用户使用?

最佳答案

export PERL_USE_UNSAFE_INC=1

根据 perldelta :

PERL_USE_UNSAFE_INC

There is a new environment variable recognised by the perl interpreter. If this variable has the value 1 when the perl interpreter starts up, then "." will be automatically appended to @INC (except under tainting).

This allows you restore the old perl interpreter behaviour on a case-by-case basis. But note that this is intended to be a temporary crutch, and this feature will likely be removed in some future perl version. It is currently set by the cpan utility and Test::Harness to ease installation of CPAN modules which have not been updated to handle the lack of dot. Once again, don't use this unless you are sure that this will not reintroduce any security concerns.

不过,我会听取建议并尽量避免设置此设置。也许在困境中,正如您所处的那样,这可能没问题,因为您已经处于安全风险之中;但我肯定会尽快更新文件并取消设置此变量。

关于Perl:将当前目录包含到@INC?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60683284/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com