in reply to Re: Capturing the nth word in a stringin thread Capturing the nth word in a string
$num = 4; for($str=~/.?/g){ $h{space} += !/\S/; $word .= $_ if $h{space} == $num-1 && /\S/ .. !/\S/ } print $word; [download]