The @+ and @- variables allow you to reference capture buffers by index rather by named variables (e.g. substr($var, $-[2], $+[2] - $-[2]) rather than $2). Similarly %+ allows access to named captures by "index" (the name).
$ perl5.10.0 -E '$_="ab cd ef gh";m/(?<foo>\S+)\s+\S+\s+(?<bar>\S+)/; +for(keys %+){say "$_:\t$+{$_}"}; say "\$+: $+";' bar: ef foo: ab $+: ef
It's not like $+ which is a special name for "whatever the last group was which matched"; $+ always going to refer to whatever the last group was which successfully matched, whereas %+ allows access to all of the named captures.
That clear things up?
Update: Oop, had @+ twice first sentence; thanks linuxer.
The cake is a lie.
The cake is a lie.
The cake is a lie.
In reply to Re: Bug in ' perldoc perlvar ' ?
by Fletch
in thread Bug in ' perldoc perlvar ' ?
by linuxer
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |