Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

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 (Monk) 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?

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2022-05-23 23:56 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (82 votes). Check out past polls.