$dir= shift || '.'; opendir DIR, $dir or die "Can't open directory $dir: $!\n"; while ($file= readdir DIR ) { next if $file !~/^\w{10,}\d{4,}\.\d{1,}/; print "Found a file: $file\n" if $file=~/^\w{10,}\d{4,}\.\d{1,}/; } print "are you sure that you want to delete $file 'Y/y(es)' "; chop ($answer = ); unlink $file or die "Can't delete $file: $!\n" if $answer =~m%^Y(es)?$%i;