Hello guru's
I want to read two files and match two keys and merge second key value to first key value.
File one
Bbbb,3333,4444
Cdd,3444,3444
Zddd,345,456
File two
Bbbb_rf1,23,45
Cdd_rf2,24.45
Zddd,34,456.4
I would make it
Bbbb,3333,4444,23,45
So I have created two hash of arrary
open (P1, "< /tmp/p1");
while (<PROJ>) {
next unless s/^(.*?),\s*//;
$pr1{$1} = [ split ];
}
open (S1, "< /tmp/s1");
while (<S1>) {
next unless s/^(.*?),\s*//;
$si1{$1} = [ split ];
}
for my $key1 (keys %pr1 ) {
for my $key (keys %si1 ) {
if (($pr1{$key1} = $sil{$key._ref1}) || $sil{$key})
print "$key: $key1\n";
I am stuck at comaparing, not sure how to go further and merge with first or new hash.Please help me.
In reply to hash help
by bkish11
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.