why does this idea sound like it's coming from: A. a student who hopes to have computer program write his 500 word essays every week.
B. a teacher who put the rule on students that s/he will ignore anything beyond 500 words. :) > -----Original Message----- > From: Daniel Gardner [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, July 16, 2002 3:37 PM > To: [EMAIL PROTECTED]; Anthony E. > Subject: Re: word count (limit) in a scalar... > > > 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] > ---------------------------------------------------------------------------- -------------------- The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]