[Israel.pm] count chars

Gabor Szabo szabgab at gmail.com
Mon Sep 3 04:17:59 PDT 2007

On 9/3/07, Amir E. Aharoni <amir.aharoni at gmail.com> 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


More information about the Perl mailing list