On Mar 9, M z said: >could someone please help me make this bit of code >more efficient? I am trying to break really long >lines, say up to 600 characters into manageable sizes >(78 or less characters) but I do not want to break >cleanly at position 78. If that is in the middle of a >word, my program back steps to the first whitepace.
I'm sure this has been asked (and answered) recently. However, it probably didn't have a good subject in its headers. $string =~ s/(.{1,78})\s/$1\n/g; That will match between 1 and 78 characters (but it tries to match the most possible) and requires that a space be the next character matched; it replaces the space with a newline. If you want to make it more rigorous, I have some ideas. Here's one that stores said chunks in @parts: @parts = $string =~ /.{1,78}(?!\S)/g; -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** <stu> what does y/// stand for? <tenderpuss> why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]