in reply to Question: File name pattern match using Grep function
Yet another way to avoid the interpolation problem would be to pre-compile your pattern into a regular expression using qr. You might also consider tightening up your grep condition in case somebody is silly enough to name a directory "confusing.txt" and if you want to exclude symbolic links if on *nix.
... my $file_mask = qr{\.txt$}; ... my @files = grep { m{$file_mask} and -f and not -l } readdir DIR; ...
I hope this is of interest.
Cheers,
JohnGG
|
|---|