Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: compare and sum hash from array

by zejames (Hermit)
on Dec 20, 2004 at 15:13 UTC ( #416205=note: print w/replies, xml ) Need Help??


in reply to compare and sum hash from array

Update : as this looks like homework, change my solution to be more cryptic, and from which I'm quite sure the OP will be able to learn from :

As you say in your title, you must use a hash:

m!([\S]+)\t(\d+)(?{$hash{$1} +=$2})! while (<DATA>); print "$_ -> $hash{$_}\n" foreach (keys %hash); __DATA__ 192.168.1 23 192.168.1 14 192.168.4 8 192.168.3 13 192.168.3 12

However, you question looks like a homework. I would be better if you provided your work so that we give you direction or better code if needed.


--
zejames

PS : anyone interested into a obfuscated context on this request ?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2020-10-24 17:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (246 votes). Check out past polls.

    Notices?