my $pattern = qr{se\d{4}ab}i; opendir(DIRHANDLE, ".") or die "Cannot opendir: $!"; unlink grep { -e and /$pattern/ } readdir DIRHANDLE;