in reply to Re: The nth occurrence of a character
in thread The nth occurrence of a character

You could go one step further and use /^$pat/ and $where = $+[0]-1, but that makes use of the @+ array, and I'd probably leave a comment on that line.

Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart

Replies are listed 'Best First'.
Re^3: The nth occurrence of a character
by diotalevi (Canon) on Feb 08, 2006 at 14:36 UTC

    This is certainly cheaper. If capturing can be avoided and this code is important for speed, choose the non-capturing version.

    ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊