develooper Front page | perl.perl5.porters | Postings from August 2008

Re: [perl #58116] glob("~user") works every 2nd time

Thread Previous
From:
Paul Johnson
Date:
August 20, 2008 02:40
Subject:
Re: [perl #58116] glob("~user") works every 2nd time
Message ID:
20080820093949.GI14981@pjcj.net
On Tue, Aug 19, 2008 at 07:49:10AM -0700, Ulrich Windl wrote:
> I have written some code that works when called the first time, and from
> then on it seems it only works every 2nd time.
> That code (from a subroutine) is:
> 
>     $homedir = glob("~ora\L$ORA_SID\E");
>     Log(0, 'E', 'logger', "~ora\L$ORA_SID\E: $!")
> 	unless ($homedir);

This is working as designed.  Please reread "perldoc -f glob" and note
that you are calling glob in scalar context.

Perhaps you wanted
      ($homedir) = glob("~ora\L$ORA_SID\E");
to call glob in list context?

-- 
Paul Johnson - paul@pjcj.net
http://www.pjcj.net

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About