This will do the trick
$input = " 1234567890123456789012345678901234567890123456789012345678901234567890 + 1234567890123456789012345678901234567890123456789012345678901234567890 + 1234567890123456789012345678901234567890123456789012345678901234567890 + 1234567890123456789012345678901234567890123456789012345678901234567890 + "; # do the magic with a snazzy regex $input =~ s[(\S+)] # grab the words into $1 { local $_ = $1; # assign word to $_ if (length $1>30) { # if word to long s/(.{30})/$1 /g; # add spaces every 30 char } $_; # substitute in $_ for word # it may or may not have changed }gex; # global, execute, comments print $input;
Note I have assumed that the words are any consecutive non whitespace chars
cheers
tachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
In reply to Re: Splitting A Word?
by tachyon
in thread Splitting A Word?
by mpegman
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |