Perl path setup

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; 

However, it only prints the original $ PATH. / Usr / local / jdk is not added. Can someone tell me what I am doing wrong?

+6
source share
2 answers

You create a shell by executing a shell command that sets the environment variable in the shell and then exits the shell without doing anything with the environment variable. You never changed perl environment. This will be done using

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

However, it is strange to add at the end of the path.

+12
source

Note that ikegami's answer will set the path only in the local Perl script and will not change it for the shell that called your Perl script.

If you want to change the path in the shell environment so that the following programs you run will also benefit from this change, you will need to use the source or "dot-space" sequence or better yet - change this to the path made in the .bashrc or .login files .

+2
source

Source: https://habr.com/ru/post/918269/


All Articles