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

Try This
$str = "The, Sample, sents, kdsjf, jdfhj"; for (split(/,/, $str,3)) { print ; }
or
$cnt =0; while($str =~ /(.*?),/g) { $cnt++; print $&, if($cnt ==3); }