GrandFather has asked for the wisdom of the Perl Monks concerning the following question:
In the process of trying to benchmark some regex code I found some odd behaviour. The code below should generate two lines of text, but only generates one. The second time through, the regex doesn't seem to generate any matches!
use warnings; use strict; gf (); gf (); sub gf { my $ins1 = '4 A -4 C -4 B 1 D'; my @inserts; $ins1 =~ /[\d+-]+(?: \w ([\d+-]+)(?{push @inserts, $1}))*/g; print "\n" . join ' ', @inserts; }
Prints
-4 -4 1
Is this a bug in the "use at own risk" code evaluation extensions to the regex engine, or something silly I've missed?
I'm using Active State Perl 5.8.7
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Irregular expression evaluation
by pg (Canon) on Oct 24, 2005 at 03:17 UTC | |
|
Re: Irregular expression evaluation
by chester (Hermit) on Oct 24, 2005 at 03:24 UTC | |
by pg (Canon) on Oct 24, 2005 at 03:46 UTC | |
by Roy Johnson (Monsignor) on Oct 24, 2005 at 20:31 UTC | |
|
Re: Irregular expression evaluation
by sauoq (Abbot) on Oct 24, 2005 at 04:14 UTC | |
by pg (Canon) on Oct 24, 2005 at 04:40 UTC | |
by demerphq (Chancellor) on Oct 24, 2005 at 07:20 UTC | |
|
Re: Irregular expression evaluation
by neversaint (Deacon) on Oct 24, 2005 at 03:43 UTC | |
|
Re: Irregular expression evaluation
by sfink (Deacon) on Oct 25, 2005 at 00:49 UTC | |
by GrandFather (Saint) on Oct 25, 2005 at 01:28 UTC |