develooper Front page | perl.perl5.porters | Postings from December 2009

[perl #71136] Regexp bugs.

Thread Next
From:
Abigail
Date:
December 9, 2009 04:38
Subject:
[perl #71136] Regexp bugs.
Message ID:
rt-3.6.HEAD-12359-1260316687-1313.71136-75-0@perl.org
# New Ticket Created by  Abigail 
# Please include the string:  [perl #71136]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=71136 >



This is a bug report for perl from abigail@abigail.be,
generated with the help of perlbug 1.39 running under perl 5.10.1.


-----------------------------------------------------------------
[Please describe your issue here]

While trying to work around bug #59792, I found some different problems:

    "a" =~ m {(?|(?<A>a)|(?<B>b))} and say $+ {B};

The code about prints 'a'. This shouldn't happen, as the (?<B>b) alternation
isn't taken.

    "a b" =~ m {(?|(?:(?<A>(?<B>a)(?<C>[^ab]*)(?<D>b))) |
                        (?:(?<B>c)(?<C>[^cd]*)(?<D>d)))}x;

Afterwards, %- is equal to:

   (A  =>  ["a b"],
    B  =>  ["a", "a b"],
    C  =>  [" ", "a"],
    D  =>  ["b", " "])


Instead of the expected:

   (A  =>  ["a b"],
    B  =>  ["a"],
    C  =>  [" "],
    D  =>  ["b"])


Replacing (?|) with (?:) solves it partially (at the expense of having
many undefined number variables), but there are still oddities. For 
instance, 'keys %+' and 'keys %-' don't always return the same set of
keys:

    "0" =~ m {(?:(?<A>0)|(?<B>1))};
    say for keys %+;    # Prints 'A'
    say for keys %-;    # Prints 'A', 'B'



All these issues are still present in 5.11.2.


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