Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

bsd_glob returns non-existent files without GLOB_NOMAGIC

by jimav (Initiate)
on Apr 10, 2013 at 22:35 UTC ( #1028049=perlquestion: print w/ replies, xml ) Need Help??
jimav has asked for the wisdom of the Perl Monks concerning the following question:

bsd_glob("/tmp/NoSuchFile") returns ("/tmp/NoSuchFile") rather than empty.

As I read the docs, this behavior should occur only with the GLOB_NOCHECK or GLOB_NOMAGIC flags.

What am I missing?

Comment on bsd_glob returns non-existent files without GLOB_NOMAGIC
Select or Download Code
Re: bsd_glob returns non-existent files without GLOB_NOMAGIC (default)
by Anonymous Monk on Apr 10, 2013 at 23:05 UTC

    What am I missing?

    You're missing flags, so the default is used

    The default, GLOB_CSH, includes GLOB_NOCHECK

      > The default, GLOB_CSH, includes GLOB_NOCHECK

      almost, its GLOB_NOMAGIC

      "GLOB_CSH"
                 For convenience, "GLOB_CSH" is a synonym for "GLOB_BRACE |
                 GLOB_NOMAGIC | GLOB_QUOTE | GLOB_TILDE | GLOB_ALPHASORT".
      
      ...

      "GLOB_NOMAGIC"
                 Same as "GLOB_NOCHECK" but it only returns the pattern if it does
                 not contain any of the special characters "*", "?" or "[".
                 "NOMAGIC" is provided to simplify implementing the historic csh(1)
                 globbing behaviour and should probably not be used anywhere else.
      

      Cheers Rolf

      ( addicted to the Perl Programming Language)

Re: bsd_glob returns non-existent files without GLOB_NOMAGIC
by LanX (Canon) on Apr 10, 2013 at 23:13 UTC
    Your pattern has no special characters to trigger expansion, as soon as you add something like * or ? an empty list will be returned unless you activate the mentioned flags.

    see File::Glob

    DB<121> use File::Glob 'bsd_glob' DB<122> bsd_glob("/tmp/noexist*") DB<123> bsd_glob("/tmp/noexist") => "/tmp/noexist"

    Cheers Rolf

    ( addicted to the Perl Programming Language)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1028049]
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (11)
As of 2014-08-28 09:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (259 votes), past polls