如何在Perl中设置环境变量?
我想将$HOME设置为与默认目录不同的目录.
解决方法
你可以这样做:
$ENV{HOME} = 'something different';
但请注意,这只会在脚本的其余部分产生影响.当您的脚本退出时,the calling shell will not see any changes.
随着perldoc -v%ENV说:
%ENV
The hash%ENV
contains your current environment. Setting a value in “ENV” changes the environment for any child processes you subsequently “fork()
” off.