in reply to Problems writing to an external file
Try open(TEST, ">$filename") or ErrorMessage("$filename: $!"); The contents of the error message will distinguish the type of failure.