Date sent: Tue, 16 Dec 2003 23:36:16 +0800 From: John Hennessy <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] Subject: Comparing Hashes with different keys. How ?
> Hi, I have two different hashes built from separate data and need to > find the common then differing items. > > $HoA1{$custnum} = [ $uid, $firstname, $lastname ]; > $HoA2{$uid} = [ $custnum, $firstname, $lastname ]; > > I have looked at examples for "Finding Common or Different Keys in Two > Hashes" but the keys must be the same. To make the keys the same I > would like to effect a reverse function but only reversing the key and > the first value leaving the remaining array items in place. my %HoA2r; while (my ($key, $value) = each %HoA2) { $HoA2r{$value->[0]} = [ $key, $value->[1], $value->[2]]; } You should probably check whether exists $HoA2r{$value->[0]} and handle the duplicate '$custnum's in the %HoA2 as well. Jenda ===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz ===== When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>