Andrew Sweger andrew at sweger.net
Fri Apr 9 14:45:03 PDT 2010

The Daily WTF doesn't show much love for Perl usually. Today I came across
a doozy.

$x = ( $x > 1 ) ? $x-- : 0;

Granted, most of the time $x is undefined (naturally) and is just throwing
warnings like crazy. It's the post-decrement that makes it so wonderfully
nutty. I'd love to ask the original developer just what they were
thinking. I'm replacing it with:

$x //= 0;
$x-- if $x > 1;

Disclaimer: The names of some scalars were changed to protect the

Andrew B. Sweger -- The great thing about multitasking is that several
                                things can go wrong at once.

More information about the spug-list mailing list