On Wed, Mar 10, 2010 at 4:56 AM, HACKER Nora <nora.hac...@stgkk.at> wrote:

> Hi list,
>
> I want to use the Env::Sourced module for setting some environment
> variables depending on the Oracle version of a certain database:
>
> ~ ~ ~~ ~ ~~ ~ ~~ ~ ~~ ~ ~~ ~ ~~ ~ ~~ ~ ~~ ~ ~~ ~ ~~ ~ ~~ ~ ~~ ~ ~~ ~ ~~
> ~ ~~ ~ ~~ ~ ~~ ~ ~
> #!/usr/bin/perl -w
> use strict;
> use warnings;
>
> sub fnc {
>        my $oraenv;
>        my $oratabpfad="/opt/ora/9.2.0.8";
>        if ($oratabpfad =~ /9.2.0.8/) {
>                print "--- IF ---\n";
>
> $oraenv="/opt/data/magna/viamg1/umgebungen/config/ora9208.env";
>                print "OraEnv: $oraenv\n";
>        } else {
>                print "--- ELSE ---\n";
>
> $oraenv="/opt/data/magna/viamg1/umgebungen/config/ora92.env";
>                print "OraEnv: $oraenv\n";
>        }
>
>        use Env::Sourced "$oraenv";
>        system 'env |grep ORA';
> }
>
> fnc ();
> ~ ~ ~~ ~ ~~ ~ ~~ ~ ~~ ~ ~~ ~ ~~ ~ ~~ ~ ~~ ~ ~~ ~ ~~ ~ ~~ ~ ~~ ~ ~~ ~ ~~
> ~ ~~ ~ ~~ ~ ~~ ~ ~
>

"use" executes at compile time - before "$oraenv" is set. Try the "require"
command:
    require Env::Sourced;
    Env::Sourced->import( $oraenv );

The perlfunc man page has more information about "use" and "require".

-- 
Robert Wohlfarth

Reply via email to