Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello people , I am very new to perl , and facing a lil problem trying to get rid of duplicate errors in a file, I have a file as below
att comcast mci comcast sprint att verizon att att att
every enter is on a new line in the file ... I need to know how to write a script which will get rid of the duplicate enteries and then save the file with the same name in the same location .. can anyone please help me on this Thank you

Replies are listed 'Best First'.
Re: Help on deleting Duplicate enteries
by CombatSquirrel (Hermit) on Aug 26, 2003 at 21:38 UTC
    perl -ni -e 'print unless $seen{$_}++' comps.dat
    Cheers, CombatSquirrel.
    Entropy is the tendency of everything going to hell.
      all I can say is DAMN ++
Re: Help on deleting Duplicate enteries
by VSarkiss (Monsignor) on Aug 26, 2003 at 21:42 UTC

    If you're on *nix or are using something like Cygwin, you don't even need to write a program. Use the sort utility:

    sort -u -o file file
    substituting for file as appropriate.

    This has the side effect of sorting the file, but you didn't indicate whether that was desirable or not.

Re: Help on deleting Duplicate enteries
by Abigail-II (Bishop) on Aug 26, 2003 at 21:32 UTC
    What did you try so far? Have you checked out the FAQ? perldoc -q duplicate. Have you searched this site?

    Abigail