in reply to Re: Challenge: fastest count of substring
in thread Challenge: fastest count of substring

Sorry I thought it's obvious, any technique based on separation at delimiters results in an incremented result, so

 $x =split /;/, $string means their are $x-1 ";" in string.

edit

IMHO the only chance to get faster than now is to find an obscure feature in unpack.

update

example:

DB<103> $_="aXaXa" => "aXaXa" DB<104> $x=split /X/ => 3 DB<105> split /X/ => ("a", "a", "a")

ooops! 8-/

DB<106> $_="XaX" => "XaX" DB<107> $x=split /X/ => 2 DB<108> split /X/ => ("", "a")

Cheers Rolf

( addicted to the Perl Programming Language)