1 #!/usr/bin/perl -w
2 # File: dupe-remover.pl
3 # Author: Tom Large - tlarge@thelug.org
4 # Location: http://www.thelug.org/docs/
5 # Description: Simple script to search an input
6 # file, and produce an output file with no
7 # duplicates. This script assumes the any
8 # duplicate entries will be grouped together.
9 # If not, this could be accomplished by adding
10 # the 'sort' function to the array containing
11 # the input file.
12
13 $grr = "ugh";
14 @ARGV = ('./happiness.txt' ) unless @ARGV;
15 while( <> )
16 {
17 $current = $_;
18 chomp $current;
19 print "$current\n";
20 if ($current ne $grr)
21 {
22 open(THEFILE, ">>./output.inf");
23 print THEFILE "$current\n";
24 close (THEFILE);
25 $grr = $current;
26 }
27 }
syntax highlighted by Code2HTML, v. 0.9.1