Published in: Perl
URL: http://answers.google.com/answers/threadview?id=25196
Sometimes I get a big list of things, and some of the things occur multiple times in the same list. A good example is a newline-delimited list of files: the same file path might be listed 4 or 5 times. So this script removes those kinds of duplicate lines.
Found at Google Answers.
#!/usr/bin/perl -w use strict; my $outfile = "no_dupes_" . $origfile; my %hTmp; while (my $sLine = <IN>) { next if $sLine =~ m/^\s*$/; #remove empty lines #Without the above, still destroys empty lines except for the first one. } close OUT; close IN; #This script was found at #http://answers.google.com/answers/threadview?id=25196
You need to login to post a comment.
