On Aug 17, 1:35 am, [email protected] ("HACKER Nora") wrote:
> Hi,
>
> Sorry for the late answer, I was kept busy at work and had no time to
> dig in ...
>
> > IIUC, couldn't you just set oraenv directly at runtime:
>
> > $oraenv = "$w_conf/ora$orapat.env"; # coalesce path + filename
> > ^^^^^^^^^
> > $ENV{ oraenv } = "$w_conf/ora$orapat.env";
>
> Charles, thanks for your answer - maybe I understood something wrong in
> the documentation for Env::Sourced?
> IIUC, with your above syntax I would set an environment variable with
> the name "oraenv" and the value of "$w_conf/ora$orapat.env" - but not
> read/set all the contents from my env-file.
>
> The docu says, the reading in of a file is done by "use Env::Sourced (qw
> /first/file/to/include.sh /second/file/to/include.sh);". Since I do not
> know the database version (and with it the version of the env-file I
> need) until sometime during the execution of my Perl programme, I can
> only "require Env::Sourced;" at the beginning and set (import) the
> environment later.
>
Hm, If you can't set oraenv directly at runtime, delaying the
import will still work.
require Env::Sourced;
... # determine version, etc.
Env::Sourced->import( qw{first/file/to/include.sh /second/file/to/
include.sh} );
The Env::Sourced import() does all the sourcing. Here're the
relevant lines from the module source itself:
sub import
{
my $class = shift;
...
#--> Loop through all of the files passed to the module and:
#--> 1) Source the file, returning it's output as a hash
#--> 2) Include the sourced files environment into the
current
#--> environment. Any unchanged environment variables
should
#--> just be passed back to us as-is.
my @envs;
while(my $file = shift)
{
carp("$file does not exist") unless(-e $file);
....
--
Charles DeRykus
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/