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 ( [id://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.

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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://667307]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (3)
As of 2024-04-26 02:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found