Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: File::Glob Ignores Dot Files

by Aristotle (Chancellor)
on Nov 26, 2003 at 11:10 UTC ( #310198=note: print w/replies, xml ) Need Help??


in reply to File::Glob Ignores Dot Files

This is known, expected and desired behaviour. The proper glob pattern to include all files other than . and .. is {[^.],.[^.],.??*,*}

Makeshifts last the longest.

Replies are listed 'Best First'.
Re^2: File::Glob Ignores Dot Files
by jrw (Scribe) on Sep 13, 2013 at 18:41 UTC
    The correct form of this glob pattern is really {.[!.],.??*,*}. Unfortunately, that has bugs in perl 5.8.8, although it works on 5.14 and 5.16. So, the actual best practice may be to avoid glob altogether and open a dirhandle yourself and read/filter the file names you get back.

      Nowadays Id just use Path::Tiny and do path($to_dir)->children. It excludes . and .. automatically, which is a great default. It also spits out Path::Tiny objects full of useful convenience methods, rather than just strings, which help make code much less grubby.

      Makeshifts last the longest.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://310198]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (8)
As of 2017-02-24 21:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (363 votes). Check out past polls.