Anthony E. wrote:

> i have a bunch of text in a scalar $text
> How would I keep the word count to a maximum, and just
> dump the rest.. ie - I only want the paragraph to
> contain 500 words, and trash the rest.

I know this isn't exaclty what you asked...

I'm taking a wild guess and thinking that what you want to do is show some 
sort of summary of various documents, and 500 words is a good size for a 
summary.

If that's the case, then I would avoid the overhead of splitting and 
joining by simply taking the first n characters of the string, where n is 
about 500 words worth of characters.

Assuming the average word has 6 characters in it:

,----[ code ]
| my $summary_size = 6 * 500;
| my $summary = $start_text;
| $summary = substr $start_text, 0, $summary_size
|   if (length($start_text) > $summary_size);
`----

Of course it all depends what you want to use the data for.

--
Best Regards,
Daniel


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to