Home  |  Linux  | Mysql  | PHP  | XML
From:Christoph Friedrich Date:Wed Mar 10 15:48:54 2010
Subject:Re: use with variable
Could I also write

eval { use Env::Sourced "$oraenv"; } or die "Error in Eval $_";

to do the use on run time?

Greets
Christoph

Jay Savage schrieb:
> On Wed, Mar 10, 2010 at 5: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;
>>
>
> [snip]
>
>
>> use Env::Sourced "$oraenv";
>> system 'env |grep ORA';
>> }
>>
>> fnc ();
>> ~ ~ ~~ ~ ~~ ~ ~~ ~ ~~ ~ ~~ ~ ~~ ~ ~~ ~ ~~ ~ ~~ ~ ~~ ~ ~~ ~ ~~ ~ ~~ ~ ~~
>> ~ ~~ ~ ~~ ~ ~~ ~ ~
>>
>> Sadly, the final "use Env::Sourced..." command does not work. I suspect
>>
>
>
> Hi Nora,
>
> Use has a special behavior that effectively wraps the module import in
> a BEGIN block. See perldoc -f use for details.
>
> This means that regardless of where you typed 'use Env::Sourced', the
> module is being imported long before you declare $oraenv. In fact, you
> should see errors about "BEGIN Failed" and "" not being exported.
>
> You should really be using require, here, instead:
>
> require Env::Sourced;
> Env::Sourced->import($oraenv);
>
> See perldoc -f require for details.
>
> HTH,
>
> -- jay
> --------------------------------------------------
> This email and attachment(s): [ ] blogable; [ x ] ask first; [ ]
> private and confidential
>
> daggerquill [at] gmail [dot] com
>
>
>


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


Your recent visits
Re: stripped output from Net::SSH2
Re: 1-line datafile, need data for another routine
Re: Simple cgi email
[svn:parrot] r31896 - trunk/compilers/pirc/heredoc
Re: Mass value assigment



  
© 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