yu.dong | c33b307 | 2024-08-21 23:14:49 -0700 | [diff] [blame^] | 1 | #!/usr/local/bin/perl
|
| 2 | $OUTPUT = shift(@ARGV);
|
| 3 | #print "$OUTPUT\n";
|
| 4 |
|
| 5 | $ITEM = shift(@ARGV);
|
| 6 | #print "$ITEM\n";
|
| 7 |
|
| 8 | @INPUT = @ARGV;
|
| 9 | #print "@INPUT\n";
|
| 10 |
|
| 11 | #@new_output = sort @INPUT;
|
| 12 | #print "@new_output\n";
|
| 13 |
|
| 14 | foreach my $file (@INPUT) {
|
| 15 | if ((-e $file) && (open(FILE_HANDLER,"<$file")))
|
| 16 | {
|
| 17 | while(<FILE_HANDLER>) {
|
| 18 | if($_ !~ /^\s/) {
|
| 19 | if($_ !~ /.+\s$/) {
|
| 20 | push @output, $_;
|
| 21 | } else {
|
| 22 | chomp;
|
| 23 | push @output, $_;
|
| 24 | }
|
| 25 | }
|
| 26 | }
|
| 27 | close(FILE_HANDLER);
|
| 28 | }
|
| 29 | else
|
| 30 | {
|
| 31 | print STDERR "[Error] fail to open $file\n";
|
| 32 | }
|
| 33 | }
|
| 34 |
|
| 35 | my %saw;
|
| 36 | @output = grep (!$saw{$_}++, @output);
|
| 37 | if(-e $OUTPUT) {
|
| 38 | open(W,">>$OUTPUT") or die "Cannot open $OUTPUT";
|
| 39 | } else {
|
| 40 | open(W,">$OUTPUT") or die "Cannot open $OUTPUT";
|
| 41 | }
|
| 42 | foreach my $def (@output)
|
| 43 | {
|
| 44 | print W "$ITEM$def\n";
|
| 45 | }
|
| 46 | close(W);
|
| 47 |
|