Cool/useful short examples of Perl?

Tom Hukins tom at
Wed Jun 8 13:17:08 BST 2011

On Wed, Jun 08, 2011 at 02:00:41PM +0200, Abigail wrote:
> I'd rather go for sacking people that don't know the difference 
> between 
>     if (something) { ... }
> and
>     unless (!something) { ... }

It's sunny outside and pubs are open:  I can think of worse times to
lose my job.

> Or does everyone think they are always equivalent?

I'm not everyone, and with a language as flexible as Perl I hesitate
to make strong statements involving words like "always", but I don't
recall encountering a situation where they differ.

In response to your question, I started out thinking about "zero but
true" values, but this doesn't matter because double negation of
truthfulness won't care about the value.  So I got stuck.

The only special situation I can think of would be when someone
overloads the "!" operator.  I would console anyone doing this on code
I maintain by mentioning that it's sunny outside and pubs are open.

I suspect I've missed lots of other interesting syntactical
peculiarities, though.  Would you mind sharing them?


More information about the mailing list