in reply to Re: Capturing the nth word in a string
in thread Capturing the nth word in a string

Here's another possibility
$num = 4; for($str=~/.?/g){ $h{space} += !/\S/; $word .= $_ if $h{space} == $num-1 && /\S/ .. !/\S/ } print $word;