| [reply] [d/l] |
That depends on your shells. At least under bash, you can use glob() to grab dot files, for example:
print "$_\n" for grep{ -f } glob(".*");
Or probably if you want to grab both dot and non-dot files:
print "$_\n" for grep{ -f } glob("{*,}.*");
Regards,
Xicheng
| [reply] |
Nope. It does not depend on your shell. At least not if you're using Perl 5.6 or later, because glob is implemented via the standard File::Glob extension and does not rely on shell anymore.
The standard behavior of <*> or glob('*') is to not consider the dot files.
| [reply] [d/l] [select] |
is it efficient with more than 100 000 files in the directory ?
if I well understand the code, each inode is loaded in memory... so do you know another mean to get this count, without need of a huge memory ?
| [reply] |
That also fails if $dir contains spaces or other glob meta characters.
| [reply] [d/l] |
That works very nicely, thank you. | [reply] |
Some people use whitespaces in paths.
Try:
my @files = <'$dir/*'>;
| [reply] |
Thanks a lot, that works great.
Does anybody know if it's possible to include variables in the file handle? For example, if I want all the .pl files starting with 'blabla' is it possible to do something like this:
my $prename = 'blabla';
my @files = <$prename*.pl>
my $count = @files
It works with just <*.pl> but I can't get the variable to work. | [reply] |
| [reply] |
Yes, it was mistake on my part - it works with variables, too. Sorry about that.
| [reply] |