Its pretty easy to do it with words... but not so easy with charachters. You could try something like;
This is line no 1 and then it continues ..... and then a line break
This is line no 2 and then it continues ..... and then a line break
This is line no 3 and this is a long line and then it continues ..... and then a line break
This is line no 4 and then it continues ..... and then a line break
|;
my $text = &cut_up($text);
print "Content-type: text/html \n\n";
print "Text returned was: $text";
sub cut_up {
my $string = $_[0];
my @cut = split / /,$text;
# if the string is less than 100 words, then lets just pass it back...
if ($#cut < 100) { return $string; }
# otherwise we can start slicing, dicing, etc...
my $count = 0;
my $back;
my $put_in = q|<DIV style="page-break-after:always"></DIV>|;
foreach (@cut) {
$count++;
if ($count =~ /00$/) {
$back = "$_ $put_in ";
} else {
$back = "$_ ";
}
return $back;
}
}
I didn't try the above code.. but it *should* work. Basically it inserts the value held in $put_in every 100 words.
Enjoy =)
Cheers
Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Code:
my $text = qq| This is line no 1 and then it continues ..... and then a line break
This is line no 2 and then it continues ..... and then a line break
This is line no 3 and this is a long line and then it continues ..... and then a line break
This is line no 4 and then it continues ..... and then a line break
|;
my $text = &cut_up($text);
print "Content-type: text/html \n\n";
print "Text returned was: $text";
sub cut_up {
my $string = $_[0];
my @cut = split / /,$text;
# if the string is less than 100 words, then lets just pass it back...
if ($#cut < 100) { return $string; }
# otherwise we can start slicing, dicing, etc...
my $count = 0;
my $back;
my $put_in = q|<DIV style="page-break-after:always"></DIV>|;
foreach (@cut) {
$count++;
if ($count =~ /00$/) {
$back = "$_ $put_in ";
} else {
$back = "$_ ";
}
return $back;
}
}
I didn't try the above code.. but it *should* work. Basically it inserts the value held in $put_in every 100 words.
Enjoy =)
Cheers
Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!