Do you know where your variables are? | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Below are some examples of "die" messages on my Windows machine for a non-existent file. I used "warn" instead of "die" so that all 4 examples would run.
In the first example, I just have the OS error code $!. Well if the code is opening many files, "which file?" is not known - although you can get the Perl source line that the error occurred on. I don't expect users to have to look into the code so that isn't ideal. The second example, I put the filename that was trying to be opened into the "die" message. That is often way more useful than the OS error code alone. Usually not to hard to figure out why that file couldn't be opened. In the third example, I put both the filename and error code. I most often include both pieces of information. Also note that I also put whether a read, write or append was attempted into the error message. In the fourth example, I suppress the output of the Perl source line number by simply appending a "\n" to the "die" string. In a lot of situations, the user doesn't care about this Perl code line and it just clutters things up and can confuse folks.
In reply to Re^3: Newby question
by Marshall
|
|