Monks
I created two HoHs and I am trying to compare the inner keys from %hash2 with the inner keys of %hash1 for each of its outer key (hash1), to calculate some score-p (from p0001, p-0002, etc) by adding the value from each logt (A, B, etc), when found; otherwise add $delta value to score. This score-p must be store in another hash
e.g. Score of p0001 compare to (A)= 0.0163934+0.0163934+$delta+$delta...
Score of p0001 compare to (B)= 0.0163934+$delta+$delta+$delta..
e.g. Score of p0002 compare to (A)= 0.0163934+0.0163934...
Score of p0002 compare to (B)= 0.0163934+0.0163934
my %hash1 = (
'A' => {
'log1' => [ '1', '0.0163934' ],
log2' => ['1','0.0163934'],
'log3' => ['1','0.0163934' ],
}
'B' => {
'log1' => [ '1', '0.0134521' ],
'log3' => ['2','0.0244508'],
}
);
my %hash2 = (
'p0001' => {
'log1' => '1',
'log2' => '3',
'log5' => '1',
'log8' => '1',...
}
'p0002' => {
'log1' => '1',
'log3' => '2',...
}
p0004 => ...,
p0056 => ...,
);
My problem is how to compare all inner keys of each p (%hash2) with all inner key of all logt (%hash1). This is what I have so far...I am stuck!
$hash1{$logt}{$keylogs}[1];
$hash2{$p}{$pkeylogs};
$hash3{$p} {$logt} =>$totalscore;
foreach my $keylogt (keys(%hash1)){
foreach my $keyp (keys(%hash2)){
foreach my $keypinner (keys %{$hash2{$keyp}}){
foreach my $keylogtinner (keys %{$hash1{$keylogt}}){
until($keypinner eq $keylogtinner){
...
$totalscore+=$hash1{$keylogt}{$keylogtinner}[1];
}
else{
$totalscore+=$delta;
}
}
}
}
}
Please I need some guidance
Thanks
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.