blob: 5ccefcb99e26d45a9bd668c005cdf174f954c460 [file] [log] [blame]
yu.dongc33b3072024-08-21 23:14:49 -07001#!/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
14foreach 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
35my %saw;
36@output = grep (!$saw{$_}++, @output);
37if(-e $OUTPUT) {
38 open(W,">>$OUTPUT") or die "Cannot open $OUTPUT";
39} else {
40 open(W,">$OUTPUT") or die "Cannot open $OUTPUT";
41}
42foreach my $def (@output)
43{
44 print W "$ITEM$def\n";
45}
46close(W);
47