develooper Front page | perl.perl5.porters | Postings from October 2011

[PATCH] In perlre, clarify how subpatterns inside DEFINEs counttowards the total.

Thread Next
From:
Brian Fraser
Date:
October 6, 2011 20:28
Subject:
[PATCH] In perlre, clarify how subpatterns inside DEFINEs counttowards the total.
Message ID:
CA+nL+naDBKvzdFAEEQT7VBHqY1Yc4TnFMBTEMgNkJzXanNaprw@mail.gmail.com
I was scratching my head for a while because of this. Basically, subpatterns
defined inside a DEFINE block count towards the total number of
captures in a regex,
so perl -E '@etc = "a" =~ /(.)(?(DEFINE)(?<example>1))/; say scalar @etc' will
output 2, not 1.

Admittedly this is covered in perlre already, but for named captures
in general; For whatever
reason I thought stuff inside DEFINEs would be different.

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About