in reply to search for nth occurrence of a pattern in a line

True, I suppose. How about:
use strict; use warnings; my ($str, $nth, $find, $p); $str = "dsf,sdg,hjhgj,gjkh"; $nth = 3; $find = ','; $str =~ m/(?:.*?$find){$nth}/g; $p = pos($str) - length($find); print substr($str, $p) if $p > -1;
That doesn't use either one :)