Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^4: Hash value sorting

by iHutch105 (Initiate)
on Aug 14, 2012 at 15:41 UTC ( #987387=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Hash value sorting
in thread Hash value sorting

You're absolutely right and I've found the problem.

I made a mistake whenever I was creating/adding to values in the hash. I had this line:

${$self->{_counts}{$key}} += $value;

This was where the scalar ref was coming from. I should note, key and value are parameter passed in, representing the obvious. This line explains why I had to do some extra, dodgy dereferencing later on and, of course, should have read:

$self->{_counts}{$key} += $value;

All seems to be sorted now. Code looks a lot tidier too. First time I've really used references much but it's been a good learning experience.

Thanks to all for the help and suggestions.


Comment on Re^4: Hash value sorting
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (10)
As of 2015-07-30 19:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (273 votes), past polls