in reply to breaking up lines along white spaces with max length
While pelagic's answer is probably the best way to go here is some script to do it too.
#!/usr/bin/perl use warnings; use strict; my $length=10; while (<DATA>) { my @bits=split; # defaults to splitng $_ on whitespace foreach (@bits) { while ((length $_) > $length) { print "long one\n"; # here we substitute an empty string for the # first $length characters and printing the # ones replaced print ((substr $_, 0, $length, "")."\n"); } print "$_\n"; } } __DATA__ This one is fine ThisOneIsNotReallySoGood Here is a mixedbagoflongbits and then reasonably shortishbutnotshorten +ough
Cheers,
R.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: breaking up lines along white spaces with max length
by pelagic (Priest) on Feb 02, 2005 at 10:51 UTC |