CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Regular Expressions: Re: [upyeronson] Counting Characters at at time.: Edit Log

Thaumaturge / Moderator

Aug 12, 2005, 5:15 AM

Views: 7407
Re: [upyeronson] Counting Characters at at time.

Well, I'm not really sure how my previous message could have helped you as you seem to have completely ignored my code when writing yours :)

So, what you actually seem to want to so is to pull data from a file, one word at a time until the next word would take you over 200 characters. Which is a completely different problem.

my $max_len = 200; 

my $string = '';
while (<FILE>) {
foreach my $word (split) {
if (length($string) + length($word) + 1 > $max_len) {
# stop there
} else {
$string .= " $word";

And, of course, this has nothing to do with regexes so it's in completely the wrong section of this site :)

Dave Cross, Perl Hacker, Trainer and Writer
Get more help at Perl Monks

(This post was edited by davorg on Aug 12, 2005, 5:16 AM)

Edit Log:
Post edited by davorg (Thaumaturge) on Aug 12, 2005, 5:16 AM

Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives