Hi Nora,
On Wednesday 10 Mar 2010 12:56:52 HACKER Nora 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 ();
> ~ ~ ~~ ~ ~~ ~ ~~ ~ ~~ ~ ~~ ~ ~~ ~ ~~ ~ ~~ ~ ~~ ~ ~~ ~ ~~ ~ ~~ ~ ~~ ~ ~~
> ~ ~~ ~ ~~ ~ ~~ ~ ~
>
> Sadly, the final "use Env::Sourced..." command does not work. I suspect
> the variable to be the problem but haven't yet found a way how to pass
> the value to the "use" command properly. No quotes at all or double
> quotes (as in code snippet) return no error, but the variables are not
> set either. Single quotes or backticks return an error, of course. But
> what's left, then?
>
>
> I have an additional question: I also tried a solution like this:
>
> if (...) {
> use Env::Sourced "/path/to/file.env";
> } else {
> use Env::Sourced "/path/to/file2.env";
> }
>
use is a compile-time statement and will always be run and evaluated at
compile-time. If you want it to be at run-time you can do:
<<<<
require Env::Sourced;
Env::Sources->import($path_to_file);
>>>>
Regards,
Shlomi Fish
> but this didn't work correctly as well, always the second file (from the
> ELSE) was sourced. Am I guessing right that the latter file was sourced
> because of the ambiguous "use" although this would not come to effect
> during script execution? Could someone explain to me kindly why exactly
> that is so?
>
> And, of course, if my questions should be better addressed to the owner
> of the module, please give me a hint.
>
>
> Regards,
> Nora
--
-----------------------------------------------------------------
Shlomi Fish http://www.shlomifish.org/
List of Portability Libraries - http://shlom.in/port-libs
Deletionists delete Wikipedia articles that they consider lame.
Chuck Norris deletes deletionists whom he considers lame.
Please reply to list if it's a mailing list post - http://shlom.in/reply .
|