develooper Front page | perl.perl5.porters | Postings from August 2004

[perl #18819] regular expression hanging

Thread Next
From:
Steve Peters via RT
Date:
August 26, 2004 08:16
Subject:
[perl #18819] regular expression hanging
Message ID:
rt-3.0.11-18819-94391.19.0327990130814@perl.org
> [hpulley@mks.com - Mon Dec 02 10:10:49 2002]:
> 
> I am looking at fixing this bug and will send a patch if I'm
>    successful but in
> the meantime, I thought I would send this report.
> 
> The following code hangs after the output of one line with Perl 5.6
>    and 5.8.
> I've tried ActivePerl 5.6 and 5.8 and our (MKS Toolkit's) Perl 5.6 and
>    5.8 and
> both exhibit the same behaviour.  Both ActivePerl and the MKS Port
>    worked fine
> at 5.0.5.
> 
>  $procName="This is a test on a Win platform #  jj # - - __ _ * * * #
>    # #";
> while ($procName =~ /\G([\w]+)|([\s]+)|([^\w\x]+)/g)
>     {
>  if (defined $1) { print " ONE $1 \n";}
>   if (defined $3)
>      {
>       print "THREE $3 \n";
>      }
>  }
> 
> Output from ActivePerl 5.8's perlbug -d:
> ---

From what I can see, the regular expression is not valid.  With warnings
and strict on, I get the following warning while the program runs:

Illegal hexadecimal digit ']' ignored at ./regex.pl line 8.

From what I can see, the regex continuously matches the "[\s]+", so it
does not hang, but instead goes into an infinite loop.  Since I've never
really used "\G" before in a regexp, I'm not sure if this is the
expected behavior or not.  Looking at perlre, there are some issues with
\G.  Is the behavior in this ticket actually a bug?

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