in reply to Take reference and then dereference die() and warn()
($die_on_error ? \&CORE::die : \&CORE::warn)->($error);
In 5.10.1, though, I am getting
Undefined subroutine &CORE::warn called
In older versions of Perl, you can still define your own subroutines and reference them (they can even be anonymous):
($die_on_error ? sub { die shift } : sub { warn shift } )->($error);
I do not find it more readable than
die $error if $die_on_error; warn $error;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Take reference and then dereference die() and warn()
by dmitri (Priest) on Nov 07, 2013 at 21:56 UTC |