Cool/useful short examples of Perl?
'lesleyb'
lesleyb at herlug.org.uk
Mon May 30 23:20:00 BST 2011
On Mon, May 30, 2011 at 04:40:26PM -0500, Avleen Vig wrote:
> 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.
>
I had previous programming experience when I started learning Perl
and I was quickly introduced to the 'unless' construct. I confess
to finding it both cute and entirely obvious. It's a shame other
languages don't have it ... shame unless unless perhaps?.
I guess it depends on the intended audience .
Kind Regards
Lesley
More information about the london.pm
mailing list