Front page | perl.perl5.porters |
Postings from June 2008
Re: Empty regex
Thread Previous
|
Thread Next
From:
David Nicol
Date:
June 19, 2008 08:48
Subject:
Re: Empty regex
Message ID:
934f64a20806190847k2a697a4dk2cea6ae6797cd8b5@mail.gmail.com
On Thu, Jun 19, 2008 at 12:54 AM, Yitzchak Scott-Thoennes
> ...but while starting to do so, I came around to the other side. It's
> possible to replace /$empty/ with length($empty)?/$empty/://, so I'd
or something like /$empty.?/ which will be essentially the same but never empty
> And there's a bug here, triggered by an
> optimization:
>
> $ perl -w
> use Test::More 'no_plan';
> my $x = qr//;
> ok("foo" =~ /foo/ && "bar" =~ /$x$x/);
> ok("foo" =~ /foo/ && "bar" =~ /$x/);
> ok 1
> not ok 2
is first of the two oks is wrong because $x$x should get optimized
down to empty, or is the second wrong because /(?-xism:)/ should not?
$ perl -le '321 =~ /321/ and print 1; 4321 =~ // and print 2; 4321 =~
/(?-xism:)/ and print 3; 4321 =~ /(?-xism:)(?-xism:)/ and print 4'
1
2
3
4
Thread Previous
|
Thread Next