* Anno Siegel suggested fix-ups for accuracy and language
Index: perlfaq6.pod =================================================================== RCS file: /cvs/public/perlfaq/perlfaq6.pod,v retrieving revision 1.30 diff -u -d -r1.30 perlfaq6.pod --- perlfaq6.pod 14 Feb 2005 18:25:48 -0000 1.30 +++ perlfaq6.pod 11 Mar 2005 16:36:34 -0000 @@ -630,17 +630,18 @@ =head2 Why does using $&, $`, or $' slow my program down? -Once Perl sees that you need one of these variables anywhere in -the program, it provides them on each and every pattern match. -The same mechanism that handles these provides for the use of $1, $2, -etc., so you pay the same price for each regex that contains capturing -parentheses. If you never use $&, etc., in your script, then regexes -I<without> capturing parentheses won't be penalized. So avoid $&, $', -and $` if you can, but if you can't, once you've used them at all, use -them at will because you've already paid the price. Remember that some -algorithms really appreciate them. As of the 5.005 release. the $& -variable is no longer "expensive" the way the other two are. +(contributed by Anno Siegel) +Once Perl sees that you need one of these variables anywhere in the +program, it provides them on each and every pattern match. That means +that on every pattern match the entire string will be copied, part of +it to $`, part to $&, and part to $'. Thus the penalty is most severe +with long strings and patterns that match often. Avoid $&, $', and $` +if you can, but if you can't, once you've used them at all, use them +at will because you've already paid the price. Remember that some +algorithms really appreciate them. As of the 5.005 release, the $& +variable is no longer "expensive" the way the other two are. + =head2 What good is C<\G> in a regular expression? You use the C<\G> anchor to start the next match on the same -- brian d foy, [EMAIL PROTECTED]