perl -w should warn about print $m++,$m,$m++

D

Dan Jacobson

Idea: -w or -W should warn if one uses ++, -- modifying a variable
twice in the same statement, as noted on perlop, else users might
think:
Should one feel bad about the apparent disorder?
$ perl -wle 'print $m++,$m,$m++'
021 #Hmm, that 2 should be 1?
Same also if one uses $m++,$m,$m++ in perlform's formats.
$ perl -wle 'print $m++ + $m + $m++'
2 #OK with me.
Moral: maybe ++ only safe with the = operator?:
$ perl -wle '$e=$m++.$m.$m++; print $e'
011
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,152
Latest member
LorettaGur
Top