blob: c5a7023d8dec244e6e3855ba44a1fd85f5e18074 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
#!/usr/bin/perl
use warnings;
use strict;
use File::Basename;
if (@ARGV != 2) {
print "usage: ", basename($0), " <regexp> <string>\n";
exit 2;
}
my $string = $ARGV[1];
my $pattern = $ARGV[0];
if ($string =~ /$pattern/) {
print "\e[0;32mmatches:\e[0m $&\n";
exit 0;
} else {
print "\e[0;31mno match\e[0m\n";
exit 1;
}
|