On Jul 30, Paul said:

>> while (<INPUTFILE>){
>>    if (not $seen{$_}) {
>>        $seen{$_} = 1;
>>         print OUTFILE;
>>     }
>>     else {
>>     }
>>   }

Here's a one-liner:

  perl -nle 'print if !$seen{$_}++'

and here's another:

  perl -pe '$_ x= !$seen{$_}++'  (attributed to some of Larry's genius)

and another, for use in a program

  $seen{$_} ||= print OUT while <IN>;

Have fun. :)

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to