John Hennessy wrote:

> 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.
>
> Examples or suggestion would be most appreciated.
> Thanks
>
> John.

my $uids_by_name = {}
foreach $fields_ref  (keys %HoA1) {
  my $uid = $fields_ref->[0];
  my $name_slice = [$fields_ref->[1,2] ];
  $uids_by_name->{$name_slice} = [] unless $uids_by_name->{$name_slice};
  push @{$uids_by_name->{$name_slice}}, $uid;
}

Oooh, yuck!  I just realized that you have a potentially insoluble problem
here.  Since you don't seem to have a cross-reference between custid and
uid, and since names are *never* determinate as references, I can't see any
way to programatically associate the two structures.

Joseph


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to