Category: >> Perl Code >> Remove Duplicate Lines from a File Bookmark and Share

<< lastnext >>

Snippet Name: Remove Duplicate Lines from a File

Description: A quick and easy code snippet to remove duplicate lines from a file.

Comment: (none)

Author: CoderZone
Language: PERL
Highlight Mode: PERL
Last Modified: March 05th, 2009

use strict;
use warnings;
my $file = '/path/to/file.txt';
my %seen = ();
   local @ARGV = ($file);
   local $^I = '.bac';
      next if $seen{$_} > 1;
print "finished processing file.";
There haven't been any comments added for this snippet yet. You may add one if you like.  Add a comment 
© | users online: 13