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

[perl #56738] Re: Some bugs in Perl regexp (core Perl issues)

Thread Next
From:
Serge
Date:
July 9, 2008 08:37
Subject:
[perl #56738] Re: Some bugs in Perl regexp (core Perl issues)
Message ID:
rt-3.6.HEAD-8814-1215615033-158.56738-75-0@perl.org
# New Ticket Created by  Serge 
# Please include the string:  [perl #56738]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=56738 >


Hello Christoph Bussenius,

 this is another bug in regexp: the special variable $^N does not work, when
a captured parenthesis has a quantifier. Example:

print "\$1=$1, \$^N=$^N, \$+=$+" if 'ab' =~ /(\w)/;

Output:
$1=a, $^N=a, $+=a

 This work well.

 Now with a quantifier:

print "\$1=$1, \$^N=$^N, \$+=$+" if 'ab' =~ /(\w)+/;

Output:
Use of uninitialized value in concatenation (.) or string at test.pl line ...
$1=b, $^N=, $+=b

 $^N is undefined! It is a bug.
 In case we write

my $a='bbb';
print "\$a=$a" if 'ab' =~ /(\w)+(?{ $a=$^N })/;

$a is undefined.

 I hope the both bugs I found will be fixed in the next Perl build, thanks.

-- 
Sincerely yours,
 Serge


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