Declare hash
SINGLE BLOCK (reading one file):
Populate hash
LOOP BLOCK (reading all other files):
Remove data that isn't common from hash
Print hash data
If you move the Print operation to LOOP BLOCK,
you'll get multiple (24) groups of output.
That's not what you want, and it would have been plainly obvious if you'd done that,
so you've probably done something different to what you've described.
You've said "I am very beginner of perl" in a couple of places.
I suspect you haven't understood the anonymous block I used in SINGLE BLOCK
and ended up with logic more like this:
Declare hash
start SINGLE BLOCK
Populate hash
LOOP BLOCK
Print hash data
end SINGLE BLOCK
An anonymous block is just code wrapped in braces:
{
# code here
}
I've used it to provide a limited lexical scope.
The variables ($fh, $k and $v) that I've declared in that block, only exist in that block;
they are quite different to, and cannot interfere in any way with,
the similarly named variables elsewhere in the code.
There's also an additional benefit: when $fh goes out of scope, Perl performs an implicit
close.
Anyway, while that's probably useful information you can add to your "beginner of perl" knowledgebase,
it's very much guesswork on my part with respect to whatever modifications you made to my original code.
If you post your changes, I can provide more concrete feedback.
|