I don't see why they had to make it set them on *every* regex match just because one uses them. Why couldn't they just add a new modifier (like /i, /x, /g, etc), and only set them if the modifier is used?WARNING: Once Perl sees that you need one of $&, $`, or $' anywhere in + the program, it has to provide them for every pattern match. This ma +y substantially slow your program. Perl uses the same mechanism to pr +oduce $1, $2, etc, so you also pay a price for each pattern that cont +ains capturing parentheses. (To avoid this cost while retaining the g +rouping behaviour, use the extended regular expression (?: ... ) inst +ead.) But if you never use $&, $` or $', then patterns without captur +ing parentheses will not be penalized. So avoid $&, $', and $` if you + can, but if you can't (and some algorithms really appreciate them), +once you've used them once, use them at will, because you've already +paid the price.
--MrNobo1024
s]]HrLfbfe|EbBibmv]e|s}w}ciZx^RYhL}e^print
In reply to Why can't $` $& $' be enabled on a per-regex basis? by MrNobo1024
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |