#! perl -slw
use strict;
our $N ||= 16;
my $longstring = do{ local $/; };
for my $n ( map{ $_*50 } 4 .. $N ) {
my $cutoff1 = 1+rindex $longstring, '<', $n;
my $cutoff2 = length $1 if $longstring =~ m[^(.{0,$n}[\.,:;!?])]s;
my $cutoff3 = 1+rindex $longstring, ' ', $n;
my $cutoff = $cutoff1 > ( $n - 25 ) ? $cutoff1
: $cutoff2 > ( $n - 25 ) ? $cutoff2
: $cutoff3;
my $substring = substr $longstring, 0, $cutoff-1;
print "\n$n($cutoff)\n'$substring'";
}
__DATA__
Welcome to the Perl Monastery. We hope your stay is long
and enjoyable. You are probably wondering what PerlMonks
is all about. Hopefully this page will answer some of those
questions.
What Perl Monks is:
Areas within the monastery: