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
In reply to Re: Question: File name pattern match using Grep function
by johngg
in thread Question: File name pattern match using Grep function
by jujiro_eb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |