$i{$_}++ for (@a); $i{$_}-- for (@b); @c=grep { $i{$_} > 0 } keys @a; @d=grep { $i{$_} < 0 } keys @b;