On 9/3/07, Amir E. Aharoni <[EMAIL PROTECTED]> wrote:
> What is the best way to count the number of times that a character
> appears in a string?
...
>
> It replaces the characters with itself and returns the number of
> substitutions, but it doesn't improve readability.

Whatever you do you can put it in a function

$n = count_chars($str, $c);

that will increase readability

Gabor
_______________________________________________
Perl mailing list
[email protected]
http://perl.org.il/mailman/listinfo/perl

Reply via email to