diff options
author | Florian Pritz <bluewind@xssn.at> | 2010-06-06 22:04:31 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xssn.at> | 2010-06-06 22:04:31 +0200 |
commit | 30e977cc418e8e71a0e9da239573fae46990a45a (patch) | |
tree | 8d4954905ef57818efadd035b8d8ed71613ae1cb | |
parent | 5d059fa82855dc2896ecd670f61722a47aaa6550 (diff) | |
download | bin-30e977cc418e8e71a0e9da239573fae46990a45a.tar.gz bin-30e977cc418e8e71a0e9da239573fae46990a45a.tar.xz |
add regcheck.pl
Signed-off-by: Florian Pritz <bluewind@xssn.at>
-rwxr-xr-x | regcheck.pl | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/regcheck.pl b/regcheck.pl new file mode 100755 index 0000000..c5a7023 --- /dev/null +++ b/regcheck.pl @@ -0,0 +1,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; +} |