open REs, "< re_file" or die "can't read re_file: $!"; while () { chomp; my $mode = substr($_, 0, 1, ''); # reverse-chop push @re, [ $mode, match_maker($_) ]; } close REs; # make me a match... ;) sub match_maker { my $pat = shift; return eval qq{ sub { \$_[0] =~ $pat } }; } #### 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"; } } }