Rev | Line | |
---|
[d79589a] | 1 | #! /usr/bin/perl -w |
---|
| 2 | |
---|
| 3 | use warnings; |
---|
| 4 | use strict; |
---|
| 5 | |
---|
| 6 | use Regexp::Assemble; |
---|
| 7 | |
---|
| 8 | if ($#ARGV + 1 < 1) { |
---|
| 9 | print "$0: list_of_regex [filter_target]\n"; |
---|
| 10 | exit 0; |
---|
| 11 | } |
---|
| 12 | |
---|
| 13 | my $regexfile = shift @ARGV; |
---|
| 14 | if (! -r $regexfile) { |
---|
| 15 | warn "$0: cannot read '$regexfile'"; |
---|
| 16 | exit 1; |
---|
| 17 | } |
---|
| 18 | |
---|
[5a32926] | 19 | my $re = Regexp::Assemble->new(file => "$regexfile", track => 1); |
---|
[d79589a] | 20 | |
---|
| 21 | my $target = shift @ARGV; |
---|
| 22 | |
---|
| 23 | my $input; |
---|
| 24 | unless (defined($target) and -f $target) { |
---|
| 25 | print STDERR "read from STDIN\n"; |
---|
| 26 | $input = *STDIN; |
---|
| 27 | } |
---|
| 28 | else { |
---|
| 29 | open $input, "<$target"; |
---|
| 30 | } |
---|
| 31 | |
---|
| 32 | my $line; |
---|
| 33 | while ($line = <$input>) { |
---|
| 34 | chomp $line; |
---|
| 35 | if ($re->match($line)) { |
---|
| 36 | print "OK: "; |
---|
| 37 | } |
---|
| 38 | else { |
---|
| 39 | print "NG: "; |
---|
| 40 | } |
---|
[5a32926] | 41 | print $line; |
---|
| 42 | if ($re->source) { |
---|
| 43 | print " /", $re->source, "/"; |
---|
| 44 | } |
---|
| 45 | print "\n"; |
---|
[d79589a] | 46 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.