opendir(TARGET, ".") or die "Can't open current directory: $!"; my $pattern = '\.pl$'; my @targets= grep {m/$pattern/} readdir TARGET; print join ("\n", @targets);