On Dec 1, yanick1@sympatico.ca said: >> $half = int(length($str)/2); >> $str =~ s{( ?)([^ ]*)(?<=^.{$half})([^ ]*)( ?)} >> { length($2) < length($3) ? "\n$2$3$4" : "$1$2$3\n" }e; > >Isn't > > $_ = 'extraterrestrial space monkeys'; > $l = length $_; > $l-- or last until s/(.{$l,})( )(.{$l,})/$1\n$3/; > >simplier? :) Yes, but slower: Benchmark: running japhy, yanick, each for at least 5 CPU seconds... japhy: @ 2902.59/s (n=14542) yanick: @ 150.28/s (n= 819) I don't find that reduction in speed as "fun". ;) 20 times slower is cause for concern in my book. And the reason for the serious drop in speed in yours is because the regex must be recompiled (over and over). -- Jeff "japhy" Pinyan japhy@pobox.com http://www.pobox.com/~japhy/ CPAN - #1 Perl Resource (my id: PINYAN) http://search.cpan.org/ PerlMonks - An Online Perl Community http://www.perlmonks.com/ The Perl Archive - Articles, Forums, etc. http://www.perlarchive.com/ ==== Want to unsubscribe from Fun With Perl? Well, if you insist... ==== Send email to <fwp-request@technofile.org> with message _body_ ==== unsubscribe