git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Randal L. Schwartz <merlyn@stonehenge.com>
Date
Mar 25, 2006, 15:07 UTC
Message-ID
<86zmje36md.fsf@blue.stonehenge.com>
In-Reply-To
<11432834111972-git-send-email-normalperson@yhbt.net>
>>>>> "Eric" == Eric Wong <normalperson@yhbt.net> 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@stonehenge.com> <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!
Previous: Eric WongNext: Junio C Hamano
Message 21 of 24 in “send-email: dependency removal, cleanup, + small feature”
  1. Eric WongMar 25, 2006
  2. 1/4 send-email: Change from Mail::Sendmail to Net::SMTPEric Wong, Mar 25, 2006
  3. Ryan AndersonMar 25, 2006
  4. Eric WongMar 26, 2006
  5. Junio C HamanoMar 26, 2006
  6. send-email: Change from Mail::Sendmail to Net::SMTPEric Wong, Mar 26, 2006
  7. Martin LanghoffApr 26, 2006
  8. Junio C HamanoApr 26, 2006
  9. Martin LanghoffApr 26, 2006
  10. Eric WongApr 28, 2006
  11. Martin LanghoffApr 28, 2006
  12. 4/4 send-email: add support for mutt aliases filesEric Wong, Mar 25, 2006
  13. Junio C HamanoMar 25, 2006
  14. Ryan AndersonMar 25, 2006
  15. send-email: address expansion for common mailersEric Wong, Mar 26, 2006
  16. Junio C HamanoMar 26, 2006
  17. Eric WongMar 26, 2006
  18. send-email: address expansion for common mailersEric Wong, May 15, 2006
  19. Ryan AndersonMay 15, 2006
  20. 3/4 send-email: lazy-load Email::Valid and make it optionalEric Wong, Mar 25, 2006
  21. Randal L. SchwartzMar 25, 2006
  22. Junio C HamanoMar 25, 2006
  23. send-email: lazy-load Email::Valid and make it optionalEric Wong, Mar 26, 2006
  24. 2/4 send-email: use built-in time() instead of /bin/date '+%s'Eric Wong, Mar 25, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.