in reply to Can I make a sub for this?

For Q2:

As long as you already have 2 hashs, each keyed by what you would like to match for duplicate, let perl do the work for you.

my $finalHash = { %$hashA, %$hashB };

That dumps $hashA into the finalHash, then dumps $hashB in. Anywhere the keys overlap B will win, otherwise you get all matches from both hashes.


___________
Eric Hodges

Replies are listed 'Best First'.
Re^2: Can I make a sub for this?
by sandrider (Acolyte) on Aug 23, 2005 at 03:22 UTC

    Hi Eric,

    Thanks for the tip. The script I have would take hashA find those that are in hashB, let me write it in pseudocodes

    if key{hashA} eq key{hashB} { print FH value{hashA} } if not found then { print FH value{hashB} }
    which means I only want those that match from hashA and those that don't match from hashB, so some of hashA will not be in the printout. Can it be done by a method similiar to your suggestion?

    Thanks.

    Desmond