Re: RFC 158 (v1) Regular Expression Special Variables

[email protected] (Uri Guttman)
Newsgroups perl.perl6.language.regex
Message-ID <[email protected].>
>>>>> "MD" == Mark-Jason Dominus <[email protected]> writes:

  >> There's also long been talk/thought about making $& and $1 
  >> and friends magic aliases into the original string, which would
  >> save that cost.

  MD> Please correct me if I'm mistaken, but I believe that that's the way
  MD> they are implemented now.  A regex match populates the ->startp and
  -> endp parts of the regex structure, and the elements of these items
  MD> are byte offsets into the original string.  

even so wouldn't the original string need to be copied if it was being
modified so $& would be aliased correctly to the old data? in the case
of m///, $& should (and according to mjd is) be be aliased directly into
the original string as there is no copy made.

so the /k option would only be added to s/// as a way to force a copy of
the original string and alias $& to it.

and $& is local to the block. i assume lexically but is there any
argument for localized?

uri

-- 
Uri Guttman  ---------  [email protected]  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.