my ($fragment) = $full_text =~ /^(.{1,200}[^\s]*)/s;
####
my @chars = split //, $full_text;
my @excerpt;
my $in_tag = 0;
my $limit=200;
# Get exactly $limit characters of text
while ( my $char = shift @chars ) {
push @excerpt, $char;
$in_tag++ if $char eq '<';
$in_tag-- if $char eq '>';
$count++ unless $in_tag;
last if $count > $limit and !$in_tag;
}
#Now make sure we get the last word until boundary
$in_tag = 0; # just in case
while ( my $char = shift @chars ){
$in_tag++ if $char eq '<';
$in_tag-- if $char eq '>';
last if $char =~/\s/ and !$in_tag;
push @excerpt, $char;
}
my $excerpt = join ('', @excerpt);
####
__DATA__
A 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.