use strict; use warnings; my (%c, @w); $_ = lc join '', ; while (m/([a-z]+(?:'[a-z]+)?)/g) { push @w, $1 if !$c{$1}++; } for (@w) { print "$_ : $c{$_}\n" if $c{$_} > 1; }