in reply to Re^2: The nth occurrence of a character (simple /$c/g)
in thread The nth occurrence of a character

If you copy the string (and then destroy the copy), then it is a waste of time to set pos($s)= -1.

It was not an off-by-two error as I consider returning -1 (a 'true' value) for 'not found' to rather suck as an interface, and prefer to avoid returning a false value (0) for 'found at 1st character' so I meant to return the position of the character as asked, not the offset to it.

- tye