in reply to Re^2: Hash w/ multiple values + merging
in thread Hash w/ multiple values + merging

You're printing out the stringified references. An easy way to inspect data structures is Data::Dumper.

  • Comment on Re^3: Hash w/ multiple values + merging

Replies are listed 'Best First'.
Re^4: Hash w/ multiple values + merging
by sophix (Sexton) on Feb 07, 2010 at 22:46 UTC
    Thanks guys, you are really helping me out here. Now I need to find out the duplicates and merge two data sets for these duplicates while discarding the unmatched ones. I used the following script to find out the duplicates, and it indeed found the common keys.
    foreach (do { my %matcher; @matcher{map lc,keys %hash1}=(); grep exists $matcher{lc $_},keys %hash2; }) { print "$_ matches\n"; }
    yet I would like to merge the two data sets, so am I doing totally wrong by bothering with the matches as an extra loop? is there a way to merge two hashes conditional on common keys?