Juerg Oehler [mailto:[EMAIL PROTECTED] wrote: : Sent: Thursday, July 17, 2003 11:09 AM : To: [EMAIL PROTECTED] : Subject: fast match count of char in string : : : hi, : : how do efficent count char 'a' in string "abdaatela" ?
Plagiarizing from perlfaq4: "How can I count the number of occurrences of a substring within a string?" There are a number of ways, with varying efficiency: If you want a count of a certain single character (a) within a string, you can use the tr/// function like so: $string = "abdaatela"; $count = ($string =~ tr/a//); print "There are $count a characters in the string"; HTH, Charles K. Clarkson -- Head Bottle Washer, Clarkson Energy Homes, Inc. Mobile Home Specialists 254 968-8328 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]