Cool/useful short examples of Perl?

Sue Spence sue at pennine.com
Wed Jun 8 07:18:33 BST 2011


This distaste is not really limited to Germans or C programmers in my
experience. Anything more complicated than

holiday.picnic() unless raining;

will ideally not appear in any code that I am required to
inspect/support/maintain.

On Wednesday, 8 June 2011, Richard Foley <richard.foley at rfi.net> wrote:
> I've found a lot of German programmers very uncomfortable with the "unless"
> keyword, (or maybe it's just c programmers).  They appear to very often prefer
> to use a construct of the form:
>
>         if ( !something ) { ...
>
> Even worse is:
>
>         unless ( !something ) { ...
>
> The brain just into tailspin goes.
>
> Where
>
> Ciao
>
> Richard
> --
> Richard Foley
> Ciao - shorter than AufWiederSehen!
> http://www.rfi.net/books.html
>
>
>> On 31 May 2011, at 15:02, David Cantrell wrote:
>> > On Mon, May 30, 2011 at 04:27:30PM +0100, Denny wrote:
>> >> On Mon, 2011-05-30 at 15:36 +0100, David Precious wrote:
>> >>> if (! Email::Valid->address($email_address) ) {
>> >>
>> >> Something wrong with 'unless'?
>> >
>> > Yes.  Most of the time you'll either have an 'else' or want to add it
>> > later, and unless ... else is Just Wrong.
>>
>> Well, in that case, it should be:
>>
>>   if (Email::Valid->address($email_address) ) {
>>     # Code for if the e-mail address is valid.
>>     ...
>>   }
>>   else {
>>     # Code you were going to write in the block above.
>>     ....
>>   }
>>
>> Otherwise your 'else' block is basically a double negative, and (IMAO) just
>> as confusing for an 'else' block for an 'unless'.
>>
>> OK, I admit, I've found myself wanting to add an 'else' block to an
>> 'unless' statement. And it's awkward, but only for the short period of
>> time it takes for me to rewrite it as an 'if' with the original code in
>> the new 'else' block.
>



More information about the london.pm mailing list