#! /usr/bin/perl use strict; use warnings; sub countt{ my $string =; my $count = 0; $string =~ s/\s*\n//g; # removes the spaces and newline character. my @arraystr =split(//,$string);#split the string acc. to each alphabet and pass it to the array. foreach my $alpha($string){ if ($alpha =~ /t/i){ # if 't' is found $count++; #increment the count return $count; } } } #my @list = qw (here is the man in the rain); print &countt;