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, Andrew Savige wrote:

> #!perl -p
> s/\S+/$&ne$l&&$m.($l=$&)/e;$m=eof||chop
> 
> #!perl -0ap
> $:="\n$F[0]";s/\n\S+/$:=$&if$&ne$:/eg
> 
> #!perl -0p
> / /;$:="\n$`";s/\n\S+/$:=$&if$&ne$:/eg

#!perl -p0
s#^(\S* )(.*)\n\1#$1$2 #m&&redo

If the input contains no duplicate lines, the "\S*" can be replaced with ".*".
Using a literal newline would shave yet another stroke.

  -Bass
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.