Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2020-10-26 22:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (254 votes). Check out past polls.

    Notices?