Re: A little text file munging golf on the list
[email protected] (Tuomo Salo)
| Newsgroups | perl.golf |
|---|---|
| Message-ID | <[email protected]> |
On Thu, 13 Mar 2003, Marius Ascheberg wrote: > #!perl -p0 > s/^((\S+).+)\n\2/$1/m&&redo > > 30 strokes, but I was not able to remove the redo. very nice, but you broke it :-) input: this go thises kablooey output: this goes kablooey this works: #!perl -p0 s/^((\S+ ).+)\n\2/$1 /m&&redo 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 and if we ever get those variable length lookbehinds in perl: #!perl -p0 s/(?<=^\1.+)\n(\S+ )/ /gm or something thereabouts :-) -bass