Home  |  Linux  | Mysql  | PHP  | XML
From:Jay Savage Date:Wed Mar 10 14:52:04 2010
Subject:Re: use with variable
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 {

[snip]

> }
>
> 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

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


Your recent visits
Re: 1-line text file with numbers, need to add to them
Re: Any Good SCM tool to manage Perl Code locally
Re: Any Good SCM tool to manage Perl Code locally
Re: Replacement in 3GB file
Re: good practice in File::Find



  
© 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