Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: comparing keys and values in different hashes

by fruiture (Curate)
on Mar 03, 2003 at 14:04 UTC ( #240029=note: print w/ replies, xml ) Need Help??


in reply to comparing keys and values in different hashes

You're very close:

foreach( keys %hash2 ){ if( exists $hash1{$_} ){ print "$_ = ",$hash2{$_}*$hash1{$_},"\n"; } }

btw.: please don't quote numbers (like '5') if you want them to be numbers and not strings: It's both confusing and (although only in microseconds) slows perl down.

my %hash = ( dog => 11, budgie => 1, #... )
--
http://fruiture.de


Comment on Re: comparing keys and values in different hashes
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2015-07-30 10:08 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 (271 votes), past polls