You ought to test if the file is really open first, and you will hopefully
get a more helpful error message:

open(LOGFILE, ">>junk.log") or die "Cannot open logfile, $!";