>>>>> "BR" == Bob Rogers <[EMAIL PROTECTED]> writes:


  BR>    I would like to point out that your code can be improved by replacing
  BR>    uses of $& and $` with parentheses in the regexes followed by $1 and
  BR>    $2.  This is from the Devel::SawAmpersand doc . . .

  BR> I was unaware of this issue; thanks for bringing it to my attention.
  BR> But Devel::SawAmpersand doesn't really explain the problem in any kind
  BR> of depth, and just talks about "massive in-memory copying."  So,
  BR> presumably, this is just a question of efficiency?

the problem only happens with s///. if you use $&, then all uses of s///
must do a full copy of the original string in case parts of it are
referred to by $& (and friends). the s/// could change the string and so
a copy must be made. this is true for all instances of s/// in your
program. if you use parens then only those instances will need extra
copies.

so $& is a waste if you don't use grabbing.

uri

-- 
Uri Guttman  ------  [EMAIL PROTECTED]  -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org
Damian Conway Perl Classes - January 2003 -- http://www.stemsystems.com/class
_______________________________________________
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to