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

If your varnames were shorter more obvious, it'd look different Re: Perl Best Practices for naming variables, About the use of the plural form for the name of variables, Re^3: What would be the easier way, Re^8: What would be the easier way, Re: Cool way to parse Space Separated Value and CSV files, Re: Perl Best Practices for naming variables, Re: What are the most basic, generic aspects of programming?, Pronounceable syntax or beloved punctuation?, How do you pronounce variable names?, How do I pronounce all this stuff, How do you pronounce "::"?,

$main $region $metric $hash %res @ymDates

$$main{$hash}{$reg}{MetricType}{$$res{Location}}{$ymDates[$start]} = $ +$main{$hash}{$reg}{MetricType}{$$res{Location}}{$ymDates[$start]} + $ +$res{Value}; $$main{$hash}{$reg}{MetricType}{$$res{Location}}{$ymDates[$start]} += +$$res{Value};

Of course, its harder to come up with varnames without good context :) But mainhash and hashtype stand out as having too many generics not easily substituted :)

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

    The variable and key names have been changed to protect the (not so) innocent. We do have long-ish variable names as rule for clarity's sake (e.g. movementCount or movementType). It does sort of decrease readability, but increases comprehension six months later when a code review occurs.

      You may consider investing in lock_keys from Hash::Util. It fixes which keys are allowed in a hash, at the cost of a small amount of speed, and thus protects you from hash key typos.


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