Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

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.

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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (11)
As of 2018-05-21 13:53 GMT
Find Nodes?
    Voting Booth?