for (@re) { my ($mode, $func) = @$_; if ($func->($string)) { # this is your pattern match! if ($mode eq '+') { print "this is ok\n"; } else { print "this matched an exception\n"; } } }