# Assuming @foo and @bar dont contain duplicates in themselves... $_{$_}++ for @foo; $_{$_}-- for @bar;