A couple of tricks might be helpful with your application.
- Instead of using a system call, use unlink
- $filename and $nfile: $nfile = "_$filename" perhaps?
- Don't permanently mangle your variables for a temporary use, like you did when processing your date: my $date = sprintf ("%04d%02d%02d", $year+1900, $m+1, $d)
- Strip out any variables that are no longer used, such as the apparently orphaned $complete.
- if($asci =~ /$asci/) translates to "If this matches itself", which is an unreliable way to say "if (1)". Remember that '.' and '*', among other things, are different in regular expressions.
- As chromatic pointed out, you can test for a file using the '-e' function instead of reading the directory table. Used something like: if (-e $file)
- Rember that if statements must have braces, unless the if comes after the statement (i.e. $x = 1 if ($foo);). You are using a C-style if here and it will not work as you expect, if at all.
As a general note, your code is highly cluttered and confusing, which is going to make it hard to maintain. Some effort spent organizing and reducing it would probably help appreciably.