in reply to RE: Re: writing a file
in thread writing a file

So let me get this straight:
  1. You got an error message while attempting to open your file (via die)
  2. If you print to the console instead of to your file, everything succeeds
  3. If you try to print to your file (which failed to open per #1), it fails
Hmm...

Did you try looking at the error message? What did the error message say? If you got an error message while attempting to open your file, I would probably have to say that the file was not opened, which explains why your print statement to the file failed to work.

Note that "die" isn't giving you an error message. It simply relays the error message to you and stops execution of your script. If the open call failed, you would not know about it unless you checked the return value of open, and did something with it (in this case, we use 'or die ...' to print out an error message if something went wrong and exit the script).

Clearly, your open is failing, for the reasons explained by the error message you received.