Posted By

counter202 on 01/25/09


Tagged

file duplicates lines


Versions (?)

Remove Duplicate Lines from a File - perl


 / Published in: Perl
 

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

  1. #!/usr/bin/perl
  2.  
  3. use strict;
  4. use warnings;
  5.  
  6. my $file = '/path/to/file.txt';
  7. my %seen = ();
  8. {
  9. local @ARGV = ($file);
  10. local $^I = '.bac';
  11. while(<>){
  12. $seen{$_}++;
  13. next if $seen{$_} > 1;
  14. }
  15. }
  16. print "finished processing file.";

Report this snippet  

You need to login to post a comment.