#!/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.
Pereant, qui ante nos nostra dixerunt!
|