in reply to Re: search for nth occurrence of a pattern in a line
in thread search for nth occurrence of a pattern in a line

pos($str) - length($&)? Ewwww. First of all, $& is a Curse, and second, you can just use $-[0] to get the same location.
while ($str =~ /,/g) { $p = $-[0], last if !--$nth }

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