Re: [PATCH 3/4] send-email: lazy-load Email::Valid and make it optional

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>>>>> "Eric" == Eric Wong <normalperson@xxxxxxxx> 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
<merlyn@xxxxxxxxxxxxxx> <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!
-
: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]