If it's code I just write for myself, I use something like:open my $fh => $file or die "Failed to open file '$file': $!\n";
oropen my $fh => $file or die "open: $!\n";
depending on how many files the program opens.open my $fh => $file or die "open '$file': $!\n";
If it's a 'write-today-discard-tomorrow' program, I use:
or evenopen my $fh => $file or die "$!\n";
I use the latter style when writing on the command line too.open my $fh => $file or die;
Note that (except in the last case) I include a trailing newline. Most of the time, I couldn't care less on which line of the program an error occurs, especially not when it's about opening files.
I've been writing some C lately, and I've started appreciating perror. Perhaps I should write a little module give similar functionality.
Abigail
In reply to Re: Perl Style: About error messges opening files
by Abigail-II
in thread Perl Style: About error messges opening files
by demerphq
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |