perlancar has asked for the wisdom of the Perl Monks concerning the following question:
A couple of questions on handling dotfiles with perl's glob(). Seems like bsd_glob() doesn't offer any special handling of dotfiles.
1. Is there an equivalent for "shopt -s dotglob"? Reading File::Glob indicates there isn't.
2. What would be the easiest to accomplish "listing all files/subdirectories including dotfiles/dotsubdirs but without the . and .." and "listing all dotfiles/dotsubdirs only, without the . and .."? I've given up on glob() for this and simply do something along the line of:
@all_files_including_dot = do { opendir my $dh, "."; grep { $_ ne '.' +&& $_ ne '..' } readdir $dh }; @all_dotfiles = do { opendir my $dh, "."; grep { $_ ne '.' && $_ ne '. +.' && /\A\./ } readdir $dh };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: glob() and dot files
by Fletch (Bishop) on Apr 13, 2020 at 04:29 UTC | |
|
Re: glob() and dot files (updated)
by haukex (Archbishop) on Apr 13, 2020 at 08:19 UTC | |
by perlancar (Hermit) on Apr 13, 2020 at 09:46 UTC | |
by haukex (Archbishop) on Apr 13, 2020 at 09:59 UTC | |
by soonix (Chancellor) on Apr 13, 2020 at 11:28 UTC | |
|
Re: glob() and dot files
by Marshall (Canon) on Apr 13, 2020 at 05:05 UTC | |
by haukex (Archbishop) on Apr 13, 2020 at 08:26 UTC | |
by Marshall (Canon) on Apr 13, 2020 at 09:04 UTC | |
by haukex (Archbishop) on Apr 16, 2020 at 20:17 UTC | |
by Marshall (Canon) on Apr 18, 2020 at 06:38 UTC |