On Fri, Jul 23, 2004 at 12:13:48PM +0200, Paul Johnson wrote:
> On Fri, Jul 23, 2004 at 03:12:22PM +0530, Jaffer Shaik wrote:
> 
> > I have the below strig
> > 
> > $str = "abckdweqadidkaaaaisdikda";
> > 
> > In the above string, I want to count the occurrences of character 'a',
> > i.e I should get count of a = 7.
> > 
> > How can i achieve this in Perl.
> 
> $count = $str =~ tr/a//;

Note that this modifiees the string.  You might want to do 

 $count = $str =~ tr/a/a/;

instead.

--Dks


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to