You need to start tracing the check_file subroutine. There is at least one questionable line in it:
open FILE,$file || die "Cant open $file!\n";
has a precedence problem. If the open fails then it will not execute the die (and we not not saying why the open failed). A better way is: open (FILE,$file) || die "Cant open $file: $!\n";
or open FILE,$file or die "Cant open $file: $!\n";
or even better open (my $fh, '<', $file) || die "Cannot open $file: $!";
Then change the occurences of FILE to $fh.
By the way, the extra '\' are required since '\' is a special character in perl strings (as in many languages). In most cases you can use '\\' or '/' in a Windows filename path, and even mix them in the same path. You probably do not need that RE. |