http://qs321.pair.com?node_id=646140


in reply to Re: Sourcing shell scripts
in thread Sourcing shell scripts

I can always set an environment variable using the built in %ENV on Unix (or you mention 'use Env' on Windows) but the idea was to make use of our existing shell environment (which is built dynamically when our software package is installed) so we can have a single source of environment settings (easier to debug, modify, etc.). We needed these shell environments set outside of the Perl script and we didn't want to duplicate them by having another Perl script to set the environment just for Perl.

The code snippet posted will source this shell environment file prior to exec'ing the Perl script, that way it's available to the Perl code. We don't run these programs by hand, they run from a cron job, and we previously had to write a shell wrapper to perform the same function that the snippet does automatically for us. Plus, now any of our shell debugging tools and utilities are using the exact same environment settings as the actual Perl scripts that run the system. Which was the whole point.

I hope this makes sense.