develooper Front page | perl.perl6.compiler | Postings from August 2011

[perl #96472] Optional named capture in regex evaluates incorrectly to one in numeric context.

From:
Ron Schmidt
Date:
August 7, 2011 12:37
Subject:
[perl #96472] Optional named capture in regex evaluates incorrectly to one in numeric context.
Message ID:
rt-3.6.HEAD-31297-1312745817-1179.96472-82-0@perl.org
# New Ticket Created by  Ron Schmidt 
# Please include the string:  [perl #96472]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=96472 >


The first output below looks ok ...

.\perl6 -e "my $m = '4' ~~ /<digit>/; say $m<digit>; say $m<digit>  +0"
4
4

But now when I make the named element optional it seems to get the 
evaluation in numeric context wrong ...

.\perl6 -e "my $m = '4' ~~ /<digit>?/; say $m<digit>; say $m<digit>  +0"
4
1


This seems fixed in nom.

Ron





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