Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: Glob strange behavior

by jhourcle (Prior)
on Aug 21, 2006 at 12:50 UTC ( #568526=note: print w/replies, xml ) Need Help??

in reply to Glob strange behavior

It's a side effect from calling glob in scalar context:

glob EXPR glob In list context, returns a (possibly empty) list of fil +ename expansions on the value of EXPR such as the standard Un +ix shell /bin/csh would do. In scalar context, glob iterates thr +ough such filename expansions, returning undef when the list + is exhausted. This is the internal function implementing t +he "<*.c>" operator, but you can use it directly. If EXPR +is omit- ted, $_ is used. The "<*.c>" operator is discussed in +more detail in "I/O Operators" in perlop.

Try instead:

... my ($filename)=glob("$path*$_*.pkl"); if (defined($filename)) ...

Update: See graff's explanation for more specifics

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://568526]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (5)
As of 2021-04-16 10:15 GMT
Find Nodes?
    Voting Booth?

    No recent polls found