in reply to Exporting variables from perl script to shell
Depends on what “everywhere” means.
In all the programs that the Perl script invokes? That's simple: set some key in %ENV. F.ex, $ENV{PATH} is the same as what passes for $PATH in the shell and changes the path inside your Perl script and for all programs that your Perl script calls.
Do you mean in the program that invoked the shell script? That's either tricky or impossible, depending on the invoking program. If the Perl script is invoked from shell, then you need to print the values as shell code, capture this output with backticks, and eval it in the shell — as in eval `perl -le'print "PATH=$ENV{PATH}:/tmp/foobar/\n"'`. Yes, it's a bit dizzying… If the invoking program is not a shell, then the answer is probably “no can do”.
Makeshifts last the longest.
|
|---|