for ( 1..90) { $line .= "word "; } ( $thirty = $line ) =~ s/^((\w+\s){1,30}).*$/$1/; print $thirty;