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

Re: Nested Cycle?

by tangent (Priest)
on Mar 02, 2012 at 16:44 UTC ( #957512=note: print w/replies, xml ) Need Help??


in reply to Nested Cycle?

To work with your existing data structure:
my $name1 = 'name1'; # or whatever my $name2 = 'name2'; # or whatever my $sum = 0; # turn Hash of Arrays into Hash of Hashes my %HOH; while (my($name,$aref) = each %{$VAR1} ) { for my $item (@$aref) { my($prop,$score) = split(',',$item); $HOH{$name}{$prop} = $score || 0; } } my $first = $HOH{$name1}; my $second = $HOH{$name2}; while (my($prop,$score) = each %{$first} ) { $sum += $score if exists $second->{$prop}; } print "Sum of $name1 in $name2 is: $sum\n"; # Prints: Sum of name1 in name2 is: 8.5889

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://957512]
help
Chatterbox?
[Corion]: So Hyperboria is an envrypted, decentralized IPv6 mesh network. I'm interested and want to look how good coverage is in my area. But the API for querying Hyperboria is only reachable over Hyperboria itself. Thanks but no thanks.

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (4)
As of 2017-06-23 07:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (536 votes). Check out past polls.