sub countt{ ... 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; # } }
If you want to stick to your own approach, I see two issues with your original code:
HTH, Rata
In reply to Re: Getting the count of a particular alphabet using subroutine
by Ratazong
in thread Getting the count of a particular alphabet using subroutine
by changma_ha
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |