http://qs321.pair.com?node_id=853315

changma_ha has asked for the wisdom of the Perl Monks concerning the following question:

Hi all..I got struck in a problem. I have wrote a code where using a subroutine i have to count the occurrence of "t". Here is my code

#! /usr/bin/perl use strict; use warnings; sub countt{ my $string =<STDIN>; my $count = 0; $string =~ s/\s*\n//g; # removes the spaces and newline character. my @arraystr =split(//,$string);#split the string acc. to each al +phabet 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;
plz help me out.. thanx in advance