Cool/useful short examples of Perl?

Denny 2011 at denny.me
Mon May 30 17:44:05 BST 2011


On Mon, 2011-05-30 at 17:30 +0100, David Precious wrote:
> On Monday 30 May 2011 16:27:30 Denny wrote:
> > On Mon, 2011-05-30 at 15:36 +0100, David Precious wrote:
> > >     if (! Email::Valid->address($email_address) ) {
> > 
> > Something wrong with 'unless'?
> 
> we're talking bits of code for people who are just 
> learning Perl, and "unless" might be somewhat new to them still; if they're 
> coming from another language, "if" is probably going to be more familiar and 
> easier to mentally parse, I'd imagine.

Hrmmmm.  I see your point, but personally I'd be reluctant to teach
people only the bits of Perl that are the same as PHP, C, whatever.
That's not going to show them any reason to start using and enjoying
Perl for its strengths.

I'd use 'unless' as a post-condition - it's almost as easy to parse as
English then.

say "Sorry, that email address is not valid." 
	unless Email::Valid->address( $email_address );

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: This is a digitally signed message part
Url : http://london.pm.org/pipermail/london.pm/attachments/20110530/d3b809ae/attachment.pgp


More information about the london.pm mailing list