Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Perl: porters
Documentation bug or brain bug? (or, what \k<name> and $+{name} refer to)
 

Index | Next | Previous | View Flat


maddingue at free

May 5, 2008, 1:21 PM


Views: 267
Permalink
Documentation bug or brain bug? (or, what \k<name> and $+{name} refer to)

Hello,


While writing an article (in French) about 5.10 regexps, a reviewer
found that what I wrote about \k<name> and $+{name} was inconsistent.
I reread perlre and perlvar, and it seems that the inconsistency lies
in perlvar:

perlre/"Capture buffers" says:

Outside the
pattern, a named
capture buffer is available via the "%+" hash. When
different buffers
within the same pattern have the same name, $+{name} and
"\k<name>"
refer to the leftmost defined group.

and later in the "Extended Patterns" section:

(?<NAME>pattern)
[...]
If multiple distinct capture buffers have the same
name then
the $+{NAME} will refer to the leftmost defined
buffer in the
match.
[...]

\k<NAME>
Named backreference. Similar to numeric
backreferences,
except that the group is designated by name and not
number.
If multiple groups have the same name then it
refers to the
leftmost defined group in the current match.

But perlvar says:

%+ Similar to @+, the %+ hash allows access to the named
capture buffers, should they exist, in the last
successful
match in the currently active dynamic scope.


Now, if I understand correctly, perlre says that \k and %+ refers to
the leftmost, IOW the *first* successful match, while perlvar says
that %+ refers to the *last* successful match.
Or am I misunderstanding something?


--
Sébastien Aperghis-Tramoni

Close the world, txEn eht nepO.

Subject User Time
Documentation bug or brain bug? (or, what \k<name> and $+{name} refer to) maddingue at free May 5, 2008, 1:21 PM
    Re: Documentation bug or brain bug? (or, what \k<name> and $+{name} refer to) davidnicol at gmail May 5, 2008, 1:52 PM
    Re: Documentation bug or brain bug? (or, what \k<name> and $+{name} refer to) rgarciasuarez at gmail May 6, 2008, 1:48 AM
    Re: Documentation bug or brain bug? (or, what \k<name> and $+{name} refer to) maddingue at free May 6, 2008, 3:01 AM
        Re: Documentation bug or brain bug? (or, what \k<name> and $+{name} refer to) rgarciasuarez at gmail May 6, 2008, 3:10 AM
    Re: Documentation bug or brain bug? (or, what \k<name> and $+{name} refer to) pagaltzis at gmx May 6, 2008, 10:22 AM
        Re: Documentation bug or brain bug? (or, what \k<name> and $+{name} refer to) demerphq at gmail May 12, 2008, 5:54 AM

  Index | Next | Previous | View Flat
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.