develooper Front page | perl.perl5.porters | Postings from July 2018

Re: [perl #133366] *COMMIT bug?

Thread Previous | Thread Next
From:
ph10
Date:
July 13, 2018 16:49
Subject:
Re: [perl #133366] *COMMIT bug?
Message ID:
26076_1531500545_5B48D7F6_26076_11_1_alpine.LNX.2.20.1807131744230.9705@quercite
On Thu, 12 Jul 2018, Abigail via RT wrote:

> What seems to happen is that the optimizer is too eager. It finds the 'D'
> in both the pattern and the string, and determines that if the pattern
> matches, it should start matching 2 characters before the 'D'. This is
> a valid strategy if the (*COMMIT) is not present, but not in the presence
> of it.

This same issue is present if (*COMMIT) is encountered in subroutine 
call:

$ perl -e 'if ("ABXABD" =~ /(?1)(A(*COMMIT)|B)D/) { print "yes\n"; } else { print "no\n"; } '
yes
$ perl -e 'if ("ABXABD" =~ /(??{""})(?1)(A(*COMMIT)|B)D/) { print "yes\n"; } else { print "no\n"; } '
no
$ 

Turning off the optimization changes the result.

Regards,
Philip

-- 
Philip Hazel

Thread Previous | 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