Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: $var{el} += 1 vs $var{el} = $var{el} + 1

by kennethk (Abbot)
on Aug 13, 2013 at 14:25 UTC ( #1049285=note: print w/ replies, xml ) Need Help??

in reply to $var{el} += 1 vs $var{el} = $var{el} + 1

Any response you'll get here is 'IMHO', so the important thing is really readability for you, both today and in a year when you have to maintain this code.

From my perspective, using a compound assignment operator improves the legibility dramatically. With the large number of hash keys present, it'd be very easy to get confused whether the keys are all the same. += makes your intent much more obvious. It also protects you from potential typos.

Make sure in migrating this code that you are actually reading the code properly. It be a real shame to put time and energy into improving the readability and break the code in the process.

#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Comment on Re: $var{el} += 1 vs $var{el} = $var{el} + 1
Download Code
Replies are listed 'Best First'.
Re^2: $var{el} += 1 vs $var{el} = $var{el} + 1
by banesong (Acolyte) on Aug 13, 2013 at 14:38 UTC

    I actually just fixed a couple of problems where the hash got deeper on the left, and not on the right (e.g. extra level was added).

    I think that we will be changing the sub to use a more sanely readable format with +=.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1049285]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (11)
As of 2015-11-26 11:18 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (697 votes), past polls