develooper Front page | perl.perl5.porters | Postings from June 2016

Re: RFC: deprecate quantifying zero-length constructs in regexpatterns

Thread Previous | Thread Next
From:
Rocco Caputo
Date:
June 3, 2016 14:22
Subject:
Re: RFC: deprecate quantifying zero-length constructs in regexpatterns
Message ID:
4F2CC7DD-6A57-4ABC-AADE-A61786BEFDD7@pobox.com
On Jun 2, 2016, at 00:56, Karl Williamson <public@khwilliamson.com> wrote:
> 
> qr/ ^ * /x warns instead with "^ *  matches null string many times", and generates code that will run a very long time.

It seems to have been fixed, or at least optimized.

It's also important to note that the warning happens when the regular expression is compiled.  A module returning patterns as strings would give its users the ability to toggle these warnings.  A module returning compiled regular expressions would need to decide for its users.

% /usr/bin/time -p perl -le 'use warnings;
use strict;
my $r = qr/ ^ * /x;
my $s = "string";
print $s =~ $r;
'
^ *  matches null string many times in regex; marked by <-- HERE in m/ ^ *  <-- HERE / at -e line 3.
1
real         0.01
user         0.00
sys          0.00

-- 
Rocco Caputo <rcaputo@pobox.com>
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