On Tue, Aug 19, 2008 at 07:49:10AM -0700, Ulrich Windl wrote: > # New Ticket Created by "Ulrich Windl" > # Please include the string: [perl #58116] > # in the subject line of all future correspondence about this issue. > # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=58116 > > > > > This is a bug report for perl from Ulrich.Windl@rz.uni-regensburg.de, > generated with the help of perlbug 1.34 running under perl v5.8.0. > > > ----------------------------------------------------------------- > [Please enter your report here] > > 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); > > Explanation: $ORA_SID is set to "C11", effectively passing "~orac11" as > argument to glob. That user exists, just as the home directory. > Perl seems to query HP-UX 11.11's pwgrd (Password and Group Hashing and > Caching daemon) each time, but every second time an empty string is returned. > Errno, if relevant has ENOENT then. > > I failed to reproduce the effect interactively in the Perl debugger. > The effect happens for two different user names. Reading perl delta docs, > I only found some other problem fixed in 5.8.5, so I wonder... This is documented to work this way, both in 'perldoc -f glob' and in the section about I/O Operators in 'perldoc perlop'. If you are evaluating a glob in scalar context, it will return all matches one-by-one, and then, after returning all matches, if will return 'undef' before starting all over. This allows you to write: while (defined (my $match = glob ("..."))) { ... } In your case, you're better off to write ($homedir) = glob ("..."); which puts the glob() in list context, returning all matches at once (and restarting each next time). AbigailThread Previous | Thread Next