Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^2: Sending filehandles?

by djp (Hermit)
on Feb 11, 2008 at 02:28 UTC ( #667307=note: print w/ replies, xml ) Need Help??


in reply to Re: Sending filehandles?
in thread Sending filehandles?

I've ... included $! in die.

You've only done half the job there :-). If you don't put both the filename and the OS error in the error message, the user can't diagnose the actual problem. OP's (unhelpful) error message:

Could not open file
Your (fractionally more helpful) error message:
Could not open file: Permission denied
This:
open(my $FILEHANDLE, ">", $filename) or die "Cannot open $filename: $!";
yields a helpful error message:
Cannot open /dev/secret: Permission denied
To be super-picky, it's "Cannot open", not "Can't open", or "Could not open", or any other variation. In English, at least.


Comment on Re^2: Sending filehandles?
Select or Download Code
Replies are listed 'Best First'.
Re^3: Sending filehandles?
by DrHyde (Prior) on Feb 12, 2008 at 11:07 UTC

    Ahhh, a useless spelling and/or grammar criticism. Which is, of course, wrong, as such things always are. "Can't open" is just fine. "Can not" needs a space in the middle.

    But a good point about spitting out the filename in the error message.

      Well it wasn't intended to be a 'spelling or grammar' criticism, is was meant to be a 'standard error message' criticism.

      Why do you say 'cannot' cannot be used?

        Because I was making a spelling/grammar point, and therefore I was required by law to insert an error.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://667307]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2015-08-01 01:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (285 votes), past polls