while ($str =~ /,/g) { $p = $-[0], last if !--$nth }