quoted
quoted
quoted
quoted
"Eric" == Eric Wong [off-list ref] writes:
Eric> +my $have_email_valid = eval { require Email::Valid or undef };
This is not necessary... if eval fails, it returns undef by definition. Your
code presumes that the non-zero last-expression-evaluated of a require is also
returned from the require, which I believe is only accidentally true, although
the behavior may be recently documented and therefore promised. (On perl 5.8,
it looks a bit fishy to me at a quick glance.)
My favorite idiom for a possibly failing eval-step is:
my $can_I_do_this = eval { riskything; 1 };
If riskything fails, eval returns undef. If it succeeds, it evaluates the 1,
and returns that.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
[off-list ref] <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!