I want to call “env.sh ” from “my_perl.pl” without forking a subshell. I tried with backtics and system like this –> system (. env.sh) [dot space env.sh] , however wont work.
I want to call env.sh from my_perl.pl without forking a subshell. I tried with
Share
Child environments cannot change parent environments. Your best bet is to parse
env.shfrom inside the Perl code and set the variables in%ENV:Given
it prints
The code can only handle simple files (for instance, it doesn’t handle
ifstatements orfoo=$(date)). If you need something more complex, then writing a wrapper for your Perl script that sourcesenv.shfirst is the right way to go (it is also probably the right way to go in the first place).Another reason to source
env.shbefore executing the Perl script is that setting the environment variables in Perl may happen too late for modules that are expecting to see them.In the file
foo:where foo.real is your Perl script.