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