Nelson Ray wrote:

Does anyone know of any sort of a function or method in perl that returns
the number of times a search string exists in a scalar.  Say, how many "a's"
are there in this sentence?  I am able to write it myself, but I was
wondering if Perl had an inherent function for cleaner operation.  I tried
looking through the list of functions at www.perldoc.com without success.
Thanks a lot for any help.


tr/// is what you need, perldoc perlop Assuming your string is in $_, the number of a's will be my $acnt = tr/a//;









-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to