in reply to Re^2: Unlink files but not in pwd
in thread Unlink files but not in pwd

You can avoid the foreach if you use map:
opendir(my $dh, './dir') || die "opendir: $!"; unlink map { "./dir/$_" } grep { /$mypattern/i } readdir $dh; closedir $dh;