----- Forwarded message from Jeff Pinyan <jeffp@crusoe.net> ----- >>From a CLPM challenge/request, I give you this: > > $half = int(length($str)/2); > $str =~ s{( ?)([^ ]*)(?<=^.{$half})([^ ]*)( ?)} > { length($2) < length($3) ? "\n$2$3$4" : "$1$2$3\n" }e; > >It turns the ' ' nearest the center of the string into a newline. This is >used for making things like > > extraterrestrial space monkeys > >into > > extraterrestrial > space monkeys Isn't $_ = 'extraterrestrial space monkeys'; $l = length $_; $l-- or last until s/(.{$l,})( )(.{$l,})/$1\n$3/; simplier? :) Joy, Yanick -- 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 ----- End forwarded message ----- -- Get back to your dreams and fantasies Leave your fingers from the cold heart If you like to survive keep your mind alive - Cold Heart, Project Pitchfork ==== Want to unsubscribe from Fun With Perl? Well, if you insist... ==== Send email to <fwp-request@technofile.org> with message _body_ ==== unsubscribe