#!/usr/bin/perl -w %common = map { lc $_, 1 } qw/ a and the /; @words = qw/ hello there Hello hello the a A /; @words = keys %{+{ map { !$common{lc $_} ? (lc $_, 1) : () } @words }}; $/ = "\n"; print @words;