在 perl 程序中设置路径 [英] Setting the path in a perl program

查看:34
本文介绍了在 perl 程序中设置路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 bluehost 服务器设置,正在尝试在我的 perl 程序中设置路径

I have a bluehost server setup and am trying to set the path in my perl program

 print "Content-type: text/html\n\n";
    my $output=`export PATH=\${PATH}:/usr/local/jdk/bin`;
    my output1=`echo \$PATH`;
    print $output1;

但是它仍然只打印原始的 $PATH./usr/local/jdk 没有被添加.谁能告诉我我做错了什么?

However it stil prints only the orginal $PATH. The /usr/local/jdk does not get added. Can anyone tell me what i am doing wrong?

推荐答案

您正在创建一个 shell,执行一个在 shell 中设置环境变量的 shell 命令,然后退出 shell,而不对环境变量做任何事情.你从未改变过 perl 的环境.这将使用

You are creating a shell, executing a shell command that sets an environment variable in the shell, then exiting the shell without doing anything with the environment variable. You never changed perl's environment. That would be done using

local $ENV{PATH} = "$ENV{PATH}:/usr/local/jdk/bin";

不过,添加到路径的末尾有点奇怪.

Kinda weird to add to the end of the path, though.

这篇关于在 perl 程序中设置路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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