The problem is to transform, say: f.$d billy f.$d knob f.$d hagus knob fred hermione harry f.$d john yanick keith yanick eugene
into: f.$d billy knob hagus knob fred hermione harry f.$d john yanick keith eugene The input text file contains no blank lines. Every line consists of two fields separated by a single space. The last line is properly newline-terminated. Don't worry about an empty input file. Some nameless amateur golfers have come up with the following solutions, all with the same golf score: #!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 Improvements welcome. /-\ http://mobile.yahoo.com.au - Yahoo! Mobile - Check & compose your email via SMS on your Telstra or Vodafone mobile.