in reply to Perl function calls.
What did you do to test it? Were you expecting a failure? Are you sure that this test method actually produces a failure?
Of note, the call to open in the sub won't throw an error on its own. You need to check its return value:
open my $p, '<', $filename or return "Could not open $filename: $!";
Which should be compatible with the way you intended to catch errors. However, I'll also point out that or die "error message" tends to be the preferred way of doing this rather than or return "error message".
"There is no shame in being self-taught, only in not trying to learn in the first place." -- Atrus, Myst: The Book of D'ni.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl function calls.
by user786 (Sexton) on Jul 07, 2014 at 15:05 UTC | |
by hardburn (Abbot) on Jul 07, 2014 at 17:34 UTC |