in reply to Find a good starting section of a long text

Maybe something like this could be adjusted to your needs?

#! perl -slw use strict; our $N ||= 16; my $longstring = do{ local $/; <DATA> }; 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__ <p> 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. </p><p> <b>What Perl Monks is:</b><br /> <li>Our attempt to make learning Perl as nonintimidating and easy to use as possible <li>A place for you and others to polish, improve, and showcase your Perl skills <li>A community which allows everyone to grow and learn from each other. </p> <p><b>Areas within the monastery:</b></p> <ul> <p><li><a href="/index.pl?node=Seekers%20of%20Perl%20Wisdom">Seekers o +f Perl Wisdom</a>-The place you can go when you have got a question on how to do something or are unsure why something just isn't working. Then other monks can offer you their wisdom and suggestions. </p>

Output:

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


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
"Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon

janitored by ybiC: Balanced <readmore> tags around longish example codeblock