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.

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 +=.