Either of these work in a directory where I have some *.pm files and a bunch of others:
use strict; my $pattern = '\.pm$'; opendir(TARGET, ".") or die "Can't open current directory: $!"; # First try my @targets = grep(/$pattern/, readdir TARGET); print join("\n", @targets), "\n\n"; # Second try rewinddir(TARGET); @targets = grep {/$pattern/} readdir TARGET; print join("\n", @targets), "\n\n";
In reply to Re: Opendir and regex
by steves
in thread Opendir and regex
by homer
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |