my $regexp = Regexp::List ->new(modifiers => 'i',quotemeta => 0) ->lis +t2re(@patterns);
What I need to do is to find out which pattern matched and then do something based on the answer. If the pattern matched was "insert update or delete" I need to take further action. The question is what is the best way of handling this ?(?-xism:(?i:(?=[acdilrsuw])(?:create (?:t(?:able|rigger)|function|defa +ult|pro[cedure]|rule|view)|d(?:rop (?:t(?:able|rigger)|default|functi +on|rule|view)|elete )|s(?:p_(?:bind(?:efault|msg|rule)|drop(?:(?:g|ro +w)lockpromote|key)|p(?:laceobject|rimarykey)|rename(?:_qpgroup)?|set( +?:pg|row)lockpromote|unbind(?:efault|msg|rule)|add_qpgroup|chgattribu +te|foreignkey|hidetext)|etuser)|(?:alter|lock) table|(?:insert|update +) |remove java|writetext)))
This example code may be called a considerable number of times (i.e. millions). Since I'm starting out in Perl I'd like to make sure I am writing reasonable code. So how do I do this without using $& ? Any help appreciated.my $regexp = Regexp::List ->new(modifiers => 'i',quotemeta => 0) ->lis +t2re(@patterns); if ($string =~ /$regexp/) { if ($& eq "insert" or $& eq "delete" or $& eq "update") { do something with $string } call a subroutine here... }
In reply to Most recent pattern match by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |