All, This is the first time I've ever seen a bunch of guys reaching for bragging rights on just how short theirs is...and to document it, too! <g>
That said, would one of you gurus take a bit of time and explain, in a tutorial sense, just what each bit of short, shorter, then shortest code does. It would be appreciated and, like a rising tide, might float all our boats -- uh, educationally, speaking. After all, such an "expansion" might be more impressive. (Okay, my apologies to my fellow professional techies of this list, I just couldn't help it. It was too good to pass up. <g>) Thanks! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ John-- [EMAIL PROTECTED] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -----Original Message----- From: John W. Krahn [mailto:[EMAIL PROTECTED]] Sent: Wednesday, October 02, 2002 8:14 AM To: [EMAIL PROTECTED] Subject: Re: remove duplicate lines Sudarshan Raghavan wrote: > > On Wed, 2 Oct 2002, Sudarshan Raghavan wrote: > > > On Wed, 2 Oct 2002, John W. Krahn wrote: > > > > > "John W. Krahn" wrote: > > > > > > > > Sudarshan Raghavan wrote: > > > > > > > > > > On Wed, 2 Oct 2002, jontn_swift wrote: > > > > > > > > > > > This is a classic case for my favorite one-liner: > > > > > > > > > > > > perl -e'while(<>){print unless $seen{$_}++}' <infile >outfile > > > > > > > > > > You favourite one-liner can be even shorter > > > > > perl -n -e 'print unless $seen{$_}++' infile >outfile > > > > > > > > You want short? :-) > > > > > > > > perl -ne'$s{$_}++||print' infile >outfile > > > > > > Or if you want something a bit more obfuscated. > > > > > > perl -pe'$+{$_}++&&y+++cd' infile >outfile > > > > > > perl -pe'$s{$_}++&&s{.+}$$s' infile >outfile > > > > Thanks for that :-), learnt a couple of things in the process of > > understanding the second one. > > At the risk of incurring the wrath of the list admin :-), to obfuscate the > second one a little more > > perl -pe'$s{$_}++&&s{$_}++' infile >outfile Very nice. Unfortunately that regex will not work if there are certain "special" characters in $_. John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]