Bug#619109: Why complicate the example by using the exact same name?

jidanni at jidanni.org jidanni at jidanni.org
Sun Mar 20 21:15:00 UTC 2011


Package: perl-doc
Version: 5.10.1-18
Severity: wishlist

Why complicate the example by using the exact same name?
man perlvar:
               For example, $+{foo} is equivalent to $1 after the following
               match:

                 'foo' =~ /(?<foo>foo)/;
How about
                 'bar' =~ /(?<foo>...)/;
instead?

By the way, the discussion of %+ there does not say if it will end up with 1
and 2, or 3 and 4 below. We must use Dumper to find the answer.
use Data::Dumper;
'1234' =~ /(?<A>1)(?<B>2)(?<A>3)(?<B>4)/;
print Dumper \%+, \%-;

Or maybe it is subject to change in future versions?

Indeed instead of being called %LAST_PAREN_MATCH one might think of it
as %LAST_FIRST_PAREN_MATCH or %FIRST_LAST_PAREN_MATCH.






More information about the Perl-maintainers mailing list