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]