in reply to Re^3: Referencing in Function not working correctly.
in thread Referencing in Function not working correctly.

OK, I got a working version. I things around as you suggested (hopefully). Now I want to make sure it is as efficient as possible. Can you please look at this code and see if it can get anymore efficient. or should I open a new thread?
sub deDuppedArray { my ($a_ref, $b_ref, $my_bonly, $my_isec_plus_bonly) = @_; # refere +nce my (%Aseen, %Bseen, %count, @isec, @diff, @union, @aonly) = (); @Aseen{@$a_ref} = (); # lookup table @Bseen{@$b_ref} = (); # lookup table foreach my $e (@$a_ref, @$b_ref) { $count{$e}++ } # put all items +in hash table foreach my $e (keys %count) { # interate over each key of hash table push(@union, $e); # keys of hash table = union if ($count{$e} == 2) { push @isec, $e; # seen more than once = intersection } else { push(@aonly, $e) unless exists $Bseen{$e}; # seen once + f +rom A = Aonly push(@$my_bonly, $e) unless exists $Aseen{$e}; # seen once + + from A = Aonly } } @$my_isec_plus_bonly = ( @isec, @$my_bonly); }