--- Carl Rogers <[EMAIL PROTECTED]> wrote:
> One word of caution.... it looks to me like this will catch
> duplicates lines, just as long as the duplicate lines follow each
> other. . . . <snip>

I posted a one-liner that does the same as the code below. =o)

> 
> while (<INPUTFILE>){
>    if (not $seen{$_}) {
>        $seen{$_} = 1;
>         print OUTFILE;
>     }
>     else {
>     }
>   }
> 
> I wish I could tell you why/how it works (I'm *still* working my way
> up to newbie status), but it does. (Magic??).. 

Not magic. =o)
the code above says:

> while (<INPUTFILE>){

  reads a line of the file into $_

>    if (not $seen{$_}) {

  checks a global hash called %seen for a key equal to $_
   (the line just read). If it WASN'T already in the hash 
   (in other words, we haven't %seen it =o) . . . 

>        $seen{$_} = 1;
>         print OUTFILE;
>     }

  then PUT it in the hash, and print the record.

>     else {
>     }
>   }

  Otherwise, we've already printed it when we put it in the hash,
  so do nothing.

Paul ;o]

__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

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

Reply via email to