Cool/useful short examples of Perl?

Avleen Vig avleen at gmail.com
Mon May 30 22:40:26 BST 2011


On Mon, May 30, 2011 at 1:35 PM, Jason Clifford <jason at ukfsn.org> wrote:
> On Mon, 2011-05-30 at 16:27 +0100, Denny wrote:
>> >     if (! Email::Valid->address($email_address) ) {
>>
>> Something wrong with 'unless'?
>
> No but lots of people appear to find "if" to be more readable
>
> If you're not worried about readability then why bother with either the
> if or unless. Just do:
>
> use Email::Valid;
> Email::Valid->address($email_address) || print "Not valid";

When you're trying to teach someone a new language, you have to relate
it to things they'll understand.
Almost every other language has if/then/else, and doing that here
would definitely be the right thing.
The perl-specific things should be left as an exercise for the reader,
after they're comfortable with the basics and not frightened away.



More information about the london.pm mailing list