You may also consider splitting your text into separate sentences rather than lines.
I believe this should make even more sense if you display an article across
multiple pages. This way, you won't end up splitting a sentence in the middle etc.
The module that would let you do this is
Lingua::EN::Sentence.
I have already used the module in a few applications of my own to great success.
For example, to spilt a piece of text in chunks of 45 sentences each, you could do
the following:
use strict; # DO THIS! (by the way, you missed that one..)
use warnings; # haha and that too..
use Lingua::EN::Sentence;
my $page_sentence_count = 45; # 45 sentences per page!
my $sentences=get_sentences($text); ## Get the sentences.
for (my $scount = 0; $scount < scalar @$sentences; $scount++) {
unless ($scount % $page_sentence_count) {
print "Next page!\n";
# do whatever you want here (say, open next file etc)
}
print $sentences->[$scount] . "\n";
}
Disclaimer: code not tested (couldn't test it well on this box)
UPDATE: In reply to
Re:Re:Posting Program
Ahh, for that, just use the
set_EOS() method of the module to specify a new 'end-of-sentence' string.
_____________________
$"=q;grep;;$,=q"grep";for(`find . -name ".saves*~"`){s;$/;;;/(.*-(\d+)
+-.*)$/;
$_=["ps -e -o pid | "," $2 | "," -v "," "];`@$_`?{print"+ $1"}:{print"
+- $1"}&&`rm $1`;
print$\;}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.