You may be able to get a better idea of what is going wrong if you include $! in your error message. This is the variable in which Perl stores the O/S error message when things like open fail, e.g.
$fn = "non_existant_file";
open IN, "<$fn" or die "open: $fn: $!\n";