Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^4: adding values of element

by Anonymous Monk
on Jan 22, 2015 at 00:35 UTC ( [id://1114085] : note . print w/replies, xml ) Need Help??


in reply to Re^3: adding values of element
in thread adding values of element

Hi johngg,

I see you recognized that the OP got tricked by using %seen and tracking the names he'd seen, when he wanted to track the numbers

You chose %names but I called it %sum

 $names{ $name } += 4; reads like "names of $name is increasing",
"names of bob is increasing" ...
but you're not increasing the names :)
you're not tracking the name,
you're tracking some attribute of name,
you're increasing the %sum, the %cash, %accountBalance,

See Re: What are the most basic, generic aspects of programming?, Re: Perl Best Practices for naming variables, About the use of the plural form for the name of variables, About the use of the plural form for the name of variables, Perl Best Practices for naming variables