|The stupid question is the question not asked|
Perl: Source shell script to for environment variables?by Gigglesworth (Initiate)
|on Feb 08, 2006 at 01:53 UTC||Need Help??|
Gigglesworth has asked for the
wisdom of the Perl Monks concerning the following question:
I'm writing a Perl script. I need it to grab some environment variables from an Oracle environment script /oracle/oracle-env.sh . Certain environment variables such as "ORACLE_HOME" are set in that file.
If/when the DBA changes /oracle/oracle-env.sh , I want my script to automatically use the new environment, just like any Unix shell command. That is, if the DBA removes "ORACLE_HOME" and replaces it with "ORACLE_FOO", I want my script to pick up those changes.
In a shell script, you can by running the command "source /oracle/oracle-env.sh" or ". /oracle/oracle-env.sh".
In Perl, I know how to RUN a shell command from within a Perl script via `` or qx() .
However, this doesn't change the environment of my current Perl script-- e.g. the script still doesn't know about "$ORACLE_HOME", for example.
Is there an equivilant of the 'source' command within Perl?
Is the simplist solution to write a shell script as a wrapper, like this?