blob: cef0e39ab31eca752baa8a98ab5f44ee3fa7f2a3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#!/usr/bin/perl -w
# Read in the filter list.
# Print out lines starting with + directly.
# Save the lines starting with - in the array @del for deleting
# the files from input later
# Save the lines starting with ! in the array @gen for transforming
# the files in input later
#
open FILTER, "<manifest-filter.lst";
while (<FILTER>) {
/^\+ *(.*)$/ and print "$1\n";
/^- *(.*)$/ and push @del, $1;
/^! *([^ ]+) +(.*)$/ and push @gen, { pat => $1, rep => $2};
}
# Loop through the standard input, deleting lines that match regexes
# in @del and performing any matching transformations.
@lines = <>;
LINE: foreach (@lines) {
for $f (@del) {
/$f/ and next LINE;
}
$l = $_;
for $f (@gen) {
%h = %$f;
$r =$l;
if ($r =~ /$h{pat}/) {
eval "\$r =~ s\@$h{pat}\@$h{rep}\@";
push @lines, $r;
}
}
print $l;
}
|