Return to Snippet

Revision: 11113
at January 25, 2009 11:42 by counter202


Initial Code
#!/usr/bin/perl

use strict;
use warnings;

my $file = '/path/to/file.txt';
my %seen = ();
{
   local @ARGV = ($file);
   local $^I = '.bac';
   while(<>){
      $seen{$_}++;
      next if $seen{$_} > 1;
      print;
   }
}
print "finished processing file.";

Initial URL
http://www.daniweb.com/code/snippet631.html

Initial Description

                                

Initial Title
Remove Duplicate Lines from a File - perl

Initial Tags
file

Initial Language
Perl