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

Re: [perl #53562] Zero-length regex bug

Thread Previous | Thread Next
From:
Bram
Date:
April 30, 2008 07:49
Subject:
Re: [perl #53562] Zero-length regex bug
Message ID:
20080430164903.uax2h1x1eswwckgc@horde.wizbit.be
Quoting James Mcclure <perlbug-followup@perl.org>:
>
> # perl zero-length regex bug
>
> # instructions:
> #  1) run with $ARGV[0] = 1, this script prints false
> #  2) run with $ARGV[0] = 2, this script prints true
> #  3) comment out the $ARGV[0] =~ /1/ line --> this script prints true
> $ARGV[0] =~ /1/;
> if ( '' =~ // ) {  print "true\n"; }
> else { print "false\n"; }
>
> -----------------------------------------------------------------

Hello,

Thank you for your bug report but this is not a bug.


If you use an empty pattern after a re then it uses the pattern of the  
last succesful match.

It is mentioned in  
http://perldoc.perl.org/perlretut.html#Using-regular-expressions-in-Perl


But perhaps it could/should be documented more clearly... (I can't  
easily find it in perlre for example - or atleast not using a basic  
search)


Kind regards,

Bram




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