From: Randal L. Schwartz Date: Sat, 25 Mar 2006 15:07:38 GMT Subject: Re: [PATCH 3/4] send-email: lazy-load Email::Valid and make it optional Message-ID: <86zmje36md.fsf@blue.stonehenge.com> In-Reply-To: <11432834111972-git-send-email-normalperson@yhbt.net> >>>>> "Eric" == Eric Wong 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 Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!