On Tue, 11 Feb 2003, Bob Rogers wrote:
> From: John Tobey <[EMAIL PROTECTED]>
>
> I would like to point out that your code can be improved by replacing
> uses of $& and $` with parentheses in the regexes followed by $1 and
> $2. This is from the Devel::SawAmpersand doc . . .
>
> I was unaware of this issue; thanks for bringing it to my attention. But
> Devel::SawAmpersand doesn't really explain the problem in any kind of
> depth, and just talks about "massive in-memory copying." So,
> presumably, this is just a question of efficiency?
Yep. If you've got a copy of _Mastering Regular Expressions_, look up
Perl's $&, $`, and $' in the index (especially pp. 273-278) -- there's a
long section explaining that any use of these constructs can have severe
performance penalties on your code, for a lot of technical reasons that I
won't try to summarize in this message (though others may want to).
The short of it is, if you can get away with it, to *never* use these
anywhere in your programs (and by proxy to that, don't use modules that
use these constructs, such as Carp.pm or English.pm). This is based on the
first edition of the book, which was written in 1997 against whatever
version of Perl was contemporary at the time (5.4x?). For NMS this might
be an appropriate constraint, but for anyone else the advice may have been
superceded by _MRE, 2nd ed._ and later versions of Perl -- I'm not sure.
--
Chris Devers [EMAIL PROTECTED]
NIH, adj. [Abbrev. Not Invented Here.]
Pertaining to a much respected and widely practiced branch of design
philosophy, unique among philosophical "schools" in that, by
definition, the adherents refuse to talk to one another. Motivated by a
fanatical hatred of plagiarism, NIH followers selflessly limit the
domain of their responsibilities to their oen humble artifacts. See
also WHEEL.
-- from _The Computer Contradictionary_, Stan Kelly-Bootle, 1995
_______________________________________________
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm