$H{$_}++ for split '', $str; if (grep $H{$_}, a..z, A..Z) { ... }