[Israel.pm] count chars

Amir E. Aharoni amir.aharoni at gmail.com
Tue Sep 4 10:30:20 PDT 2007


On 04/09/07, Gaal Yahas <gaal at forum2.org> wrote:
> 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?
> > Is there a way to do it without the intermediate array?
>
> Yes.
>
> my $count = () = $string =~ /a/g;

Yep - someone already mentioned the goatse oprator. (It took me a
second to understand the goatse connection...)

But did anyone notice the weird performance problem i posted earlier?..



More information about the Perl mailing list