$text="Tommy tom ticked a tick at the ticket counter"; $t_count=($text=~ y/[tT]/t/); print "This text has $t_count Ts\n"; #result #This text has 9 Ts