my $regexp = Regexp::List ->new(modifiers => 'i',quotemeta => 0) ->list2re(@patterns); if ($string =~ /$regexp/) { if ($& eq "insert" or $& eq "delete" or $& eq "update") { do something with $string } call a subroutine here... }