How can I export the calling environment correctly into a subshell in Perl?
environment, path, perl
Solution
Check the PATH and modify its content if needed:
use Env qw(@PATH);
# check the PATH:
print join("\n", @PATH);
# modify its content:
push @PATH, "/usr/bin/wpj";
The official manual for this module.
Problem
I am trying to use a Perl script to add certain directories in a tool(wpj) we have. The direct command would look something like ``` $ wpj add path/to/desired/library makefile.wpj ``` I want to do a script to automate this since a lot of this has to be done. However, a very special set of environment variables among other things are setup to make 'wpj'. If I call wpj with backquotes from Perl, the call fails. You can see the code below ``` $command = "wpj add library path\\to\\file.wpj \\path\\to\\add"; print $command."\n"; $result = `$command`; print "->".$result."\n"; ``` For this I get ``` wpj: not found ``` However, the same call from the shell succeeds. Something is not correctly exported, could you please give me suggestions on how to export the calling environment into the subshell created by backquotes?