Home  |  Linux  | Mysql  | PHP  | XML
From:Robert Wohlfarth Date:Wed Mar 10 14:33:55 2010
Subject:Re: use with variable
On Wed, Mar 10, 2010 at 4:56 AM, HACKER Nora <nora.hacker@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

Navigate in group perl.beginners at sever nntp.perl.org
Previous Next


Your recent visits
Re: Reading BInary file.
Windows Services and Logical Volume Monitoring Script ....
Re: 1-line text file with numbers, need to add to them
Re: 1-line text file with numbers, need to add to them
Re: running stats on a file



  
© No Copyright
You are free to use Anything, but please consult your advocate before doing so as this website
also list content from other sources which may be copyrighted.
Site Maintained by Zareef Ahmed
Powered By PHP Consultants