diff options
author | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
commit | e0c6872cf40896c7be36b11dcc744620f10adf1d (patch) | |
tree | 60335e10d2f4354b0674ec22d7b53f0f8abee672 /dviware/catdvi/manifest-filter.pl |
Initial commit
Diffstat (limited to 'dviware/catdvi/manifest-filter.pl')
-rwxr-xr-x | dviware/catdvi/manifest-filter.pl | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/dviware/catdvi/manifest-filter.pl b/dviware/catdvi/manifest-filter.pl new file mode 100755 index 0000000000..cef0e39ab3 --- /dev/null +++ b/dviware/catdvi/manifest-filter.pl @@ -0,0 +1,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; +} + |