Hi,
I have successfully built a hash table and have two separate keys that I need to manage. I want to do the following:
list1 = (a b c d e f g)
list2 = (a b c d e f g)
key1 = (a b c)
key2 = (f g)
If key1 is matched between list1 and list2 write to a file. Then, after the key1 match is made, check if key2 is NOT matched between list1 and list2 then write to another file.
Here is a snippet of code I currently have:-
$AstPDSlackHash{$aststartendwclks} = join (" ",$aststartendwclks,$astp
+dslack);
$PTPDSlackHash{$ptstartendwclks} = join (" ",$ptstartendwclks,$ptpdsla
+ck);<br>
foreach (keys %AstPDSlackHash) {
print XLOUT ("$AstPDSlackHash{$_} $PTPDSlackHash{$_}\n") if exists
+ $PTPDSlackHash{$_};
}
What is the best way to do a second match with my second key? In other words, instead of printing to a file named XLOUT, stash the match in something (?) and then scrub that something with the second key. When the second keys do not match, write to a second file.
Here is my second set of keys:-
for ($i = 7; $i <= $astlast; $i++) {$astmasterlist = join (" ",$astmat
+erlist,$in2sal[$i]);
}
for ($i = 7; $i <= $ptlast; $i++) {$ptmasterlist = join (" ",$ptmaster
+list,$in2sal[$i]);}
GOAL: Take the keys $ptmasterlist and $astmasterlist and make sure they match in the original hash, but don't bother looking at anything that doesn't end up in XLOUT.
Here's my best guess:-
$AstPDSlackHash{$aststartendwclks,$astmasterlist} = join (" ",$aststar
+tendwclks,$astpdslack,$astmasterlist);
$PTPDSlackHash{$ptstartendwclks,$ptmasterlist} = join (" ",$ptstartend
+wclks,$ptpdslack,$ptmasterlist);
foreach ($astmasterlist %AstPDSlackHash) {
print XLOUT2 ("$AstPDSlackHash{$_} $PTPDSlackHash{$_}\n") if $ptma
+sterlist !exists $PTPDSlackHash{$_};
}
But I know that is wrong...
My god, why is this so hard to explain? Need more java...
Thanks!
Janitored by holli - added code tags
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.