use HTML::TokeParser::Simple;
my $doc = qq(story on GettingIt about hacking polls. Contrary to what the article says, Time is not checking for multiple votes on their poll. And I'm happy to report that despite the fact that my cheater scripts aren't running, I'm still beating Bill Gates.);
my $doc2;
my $total = 0;
my $p = HTML::TokeParser::Simple->new( \$doc );
while ( my $token = $p->get_token ) {
if ($token->is_text) {
if (length($token->return_text) + $total <= 200) {
$doc2 .= $token->return_text;
$total += length($token->return_text);
}
else {
for (split / /, $token->return_text) {
if ($total + length($_) <= 200) {
$doc2 .= $_ . ' ';
$total += length($_) + 1;
}
else {
last;
}
}
chop($doc2) if $doc2 =~ /\s$/;
}
}
else {
$doc2 .= $token->as_is;
}
}
print $doc2;
####
story on GettingIt about hacking polls. Contrary to what the article says, Time is not checking for multiple votes on their poll. And I'm happy to report that despite the fact that my cheat
er scripts