in reply to Pattern Matching

You ought to check to see if your opendir call succeeds. Here's my take on the regex:
if ($file =~ /^0{12}(\d{5})A001$/) { next unless ($1 > 1 and $1 < 10174); # unlink $file goes here }