#! 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:
##
P:\test>junk -N=8
200(199)
'
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.
'
250(236)
'
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:
'
300(297)
'
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:
- Our attempt to make learning Perl as nonintimidating
and'
350(345)
'
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:
- Our attempt to make learning Perl as nonintimidating
and easy to use as possible
- A place for you and'
400(396)
'
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:
- Our attempt to make learning Perl as nonintimidating
and easy to use as possible
- A place for you and others to polish, improve, and
showcase your Perl'