Also look at the explanation in the following snippet, from previous posts
#!/usr/bin/perl #The difference between qr// and the /o modifier as I understand it is + #that with /o you can never change the pattern, whereas with qr// you #can compile the pattern to be used as part of a larger regex. @regexes = (); for $pattern (@patterns) { push @regexes, qr/$pattern/; } for $item (@data) { for $re (@regexes) { if ($item =~ /$re/) { print "Matches!\n"; } } } #/o and qr// provide different services to the programmer: #/o says 'Take this pattern and create a compiled regex that will not +change #for the life of the program' #qr// says 'Take this pattern and return a special object that I can a +ssign #to a variable, interpolate into another pattern, pass to a subroutine +, #etc, etc, and as a side-effect creates a compiled form that I can use + in #pattern matches directly.'
In reply to Re: Precompiling qr/.../o question
by zentara
in thread Precompiling qr/.../o question
by vit
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |