in reply to How do I get an array which is the logical AND of the elements of two other arrays?

Disclaimer: don't blame me for (ab)using weird idioms.
This only maintains the ordering of the elements if your arrays were already sorted initially.
my @A = (1,3,4,5,6,8); my @B = (1,3,5,7,9); my (%A, %B, @C); @A{@A} = (1) x @A; @B{@B} = (1) x @B; @C = grep { delete $B{$_} && delete $A{$_} } sort keys %A; @A = sort keys %A; @B = sort keys %B;

acid06
perl -e "print pack('h*', 16369646), scalar reverse $="
  • Comment on Re: How do I get an array which is the logical AND of the elements of two other arrays?
  • Download Code