I've played and played with this on 2k.
There are 2 ways that I can recreate this error, but neither of them seem applicable.
First, if I don't have the die statement after the open, and use a bad filename I get the error after the close. This is obvious.
Second, if the file has only read permissions, and I print to it (with a die statement on the print) I get the same error, which is only slightly less obvious.
In your code though, you are not modifying the file in anyway, and have the die statement after the open.
If you attempt to simply open and close the filehandle (for the file that you are having the problem with) in a seperate script does the same thing happen? Is this happening with
every file, or is it just one (I ask that because I see this in a subroutine, I'm assuming multiple files)?
Is this code cut and pasted from your script or did you retype it here? I've retyped the code a couple of times, rather than pasting it in and noticed that my code I'm submitting here and the code I'm having the problem with has occasionaly differed subtly (with the difference being what was causing the problem).
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.