You're viewing a comment by Tom Legrady and its responses.

Tom Legrady Permalink
November 30, 2009, 17:08

The inchworm on a stick may do something, but since it duplicates a standard operator, pre-decrement, it isn't very useful.

Your choices are

$b = --$a;

Which is documented in the manual, so everyone should know what it means, and the cryptic and arcane

$b = ~-$a;

I suppose if you enjoy proving your superiority by doing things no one knows, you'll prefer the second. Personally, I prefer to not have my sleep interrupted at 3 am by someone wanting an explanation of weird code in a program that stopped working. There are enough useful and valid Perl idioms that beginners don't know, no need to add an unneccessary one.

Comment Responses

April 19, 2012, 15:14

Actually, these are not the same.

--$a will decrement $a.

~-$a will decrement $a, but will not go negative.

Reply To This Comment

(why do I need your e-mail?)

(Your twitter handle, if you have one.)

Type the word "quake3_173": (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.