Öznur Taştan wrote:

http://www.perl.com/pub/a/2002/06/04/apo5.html?page=8

    $_ = "abracadabra";
        @all = m:any /a.*?a/;
produces:

    abra abraca abracada abracadabra aca acada acadabra ada adabra abra
 Is there a version available that supports this structure?
Or are there any creative ideas of Perl wizards?
Thanks in advance

That is what will be supported in Perl 6 - so unless you have - say - Perl 5.9 bleeding running in production -- you will prolly have to wait a few more days? weeks? months? before Perl 6 is considered production.



In the meantime, try this test for development of R/E tests:


perl -w -Mre=debug -e '"abracadabra" =~ m/a.*a/g;'


For example -


perl -w -Mre=debug -e '"abracadabra" =~ m/a.*a/g;'
Freeing REx: `","'
Compiling REx `a.*a'
size 7 Got 60 bytes for offset annotations.
first at 1
1: EXACT <a>(3)
3: STAR(5)
4: REG_ANY(0)
5: EXACT <a>(7)
7: END(0)
anchored `a' at 0 floating `a' at 1..2147483647 (checking floating) minlen 2
Offsets: [7]
1[1] 0[0] 3[1] 2[1] 4[1] 0[0] 5[0]
Guessing start of match, REx `a.*a' against `abracadabra'...
Found floating substr `a' at offset 3...
Found anchored substr `a' at offset 0...
Guessed: match at offset 0
Matching REx `a.*a' against `abracadabra'
Setting an EVAL scope, savestack=3
0 <> <abracadabra> | 1: EXACT <a>
1 <a> <bracadabra> | 3: STAR
REG_ANY can match 10 times out of 2147483647...
Setting an EVAL scope, savestack=3
10 <abracadabr> <a> | 5: EXACT <a>
11 <abracadabra> <> | 7: END
Match successful!
Freeing REx: `"a.*a"'



Or, another example:


perl -w -Mre=debug -e '"abracadabra" =~ /r.*a/;'
Freeing REx: `","'
Compiling REx `r.*a'
size 7 Got 60 bytes for offset annotations.
first at 1
1: EXACT <r>(3)
3: STAR(5)
4: REG_ANY(0)
5: EXACT <a>(7)
7: END(0)
anchored `r' at 0 floating `a' at 1..2147483647 (checking floating) minlen 2
Offsets: [7]
1[1] 0[0] 3[1] 2[1] 4[1] 0[0] 5[0]
Guessing start of match, REx `r.*a' against `abracadabra'...
Found floating substr `a' at offset 3...
Found anchored substr `r' at offset 2...
Starting position does not contradict /^/m...
Guessed: match at offset 2
Matching REx `r.*a' against `racadabra'
Setting an EVAL scope, savestack=3
2 <ab> <racadabra> | 1: EXACT <r>
3 <abr> <acadabra> | 3: STAR
REG_ANY can match 8 times out of 2147483647...
Setting an EVAL scope, savestack=3
10 <abracadabr> <a> | 5: EXACT <a>
11 <abracadabra> <> | 7: END
Match successful!
Freeing REx: `"r.*a"'



Note the line: REG_ANY can match 10 times out of 2147483647...


... it will help you avoid infinity. HTH/Sx

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to