$ perl -le '$alpha = "abcdefghijklmnopqrstuvwxyz"; $str = "This is a String"; print grep { ($_) } map { 1 + index($alpha, $_), "\n" } split //,lc($str)' __output__ 20 8 9 19 9 19 1 19 20 18 9 14 7