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