Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

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
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?

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2023-09-26 22:09 GMT
Find Nodes?
    Voting Booth?

    No recent polls found