En op 13 maart 2003 sprak Bass:
> here's another (equal length, stupid \Q :-)
> this works since perl kindly resets the //g search upon modify.
>
> #!perl -p0
> s/\G\n\Q$1/ /while/(\S+ ).*/g

I enjoyed this clever solution. It works for Perl 5.6.1 and 5.8.0
but not for Perl 5.005_03.

> and if we ever get those variable length lookbehinds in perl:
>
> #!perl -p0
> s/(?<=^\1.+)\n(\S+ )/ /gm
>
> or something thereabouts :-)

Yes, I was frustrated in the extreme because that seemed the natural
way to solve this problem. BTW, I was able to whittle 4 strokes from
my original try:

-0p s/^\S+/$:=$&if$&ne$:/gem;s/\n / /g

but this line of play is a dead horse it would seem.

/-\



http://mobile.yahoo.com.au - Yahoo! Mobile
- Check & compose your email via SMS on your Telstra or Vodafone mobile.

Reply via email to