Fri, 25 Mar 2022 22:20:17 +0100
camonitor_sort.pl: Support inverse regexp matches.
Ignore-this: 83c9ddf1aa66873b077df8d23f36f5712a1d4214a5980d5a6fb497dfb147253ab3a52b88d7eae4f0
bin/camonitor_sort.pl | file | annotate | diff | comparison | revisions |
--- a/bin/camonitor_sort.pl Fri Mar 04 10:33:54 2022 +0100 +++ b/bin/camonitor_sort.pl Fri Mar 25 22:20:17 2022 +0100 @@ -94,14 +94,28 @@ sub mk_regexp { my($funcname,$regexp)= @_; + my $invert= 0; return if (!defined $regexp); + if ($regexp =~ /^!(.*)/) + { + $regexp= $1; + $invert= 1; + } + if ($regexp !~ /^\//) { $regexp= '/' . $regexp . '/'; }; #die "eval:\"sub n_regexp { return(\$_[0]=~ $regexp); }\""; - eval("sub $funcname { return(\$_[0]=~ $regexp); }"); + if (!$invert) + { + eval("sub $funcname { return(\$_[0]=~ $regexp); }"); + } + else + { + eval("sub $funcname { return(\$_[0]!~ $regexp); }"); + } if ($@) { die "error: eval() failed, error-message:\n" . $@ . " " }; } @@ -214,6 +228,9 @@ Syntax: $sc_name {options} + Note: every regexp that starts with '!' is a "do not match" regexp. In this + case theresults are the ones that DO NOT match. + options: -h: help --summary: give a summary of the script