Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
> Thus Perl allows such constructs, by forcefully breaking the infinite loop.

Thanks, that wasn't clear to me.

BUT I should have taken more care about the

> WARNING: Difficult material (and prose) ahead. This section needs a rewrite.

FWIW, the forced break can be seen with re 'debug'

D:\tmp>perl -Mre=debug -e"'foo' =~ m{ ( o? )* }x;" Compiling REx " ( o? )* " Final program: 1: CURLYX[0]{0,INFTY} (12) 3: OPEN1 (5) 5: CURLY{0,1} (9) 7: EXACT <o> (0) 9: CLOSE1 (11) 11: WHILEM[1/1] (0) 12: NOTHING (13) 13: END (0) minlen 0 Matching REx " ( o? )* " against "foo" 0 <> <foo> | 0| 1:CURLYX[0]{0,INFTY}(12) 0 <> <foo> | 1| 11:WHILEM[1/1](0) | 1| WHILEM: matched 0 out of 0..65535 0 <> <foo> | 2| 3:OPEN1(5) 0 <> <foo> | 2| 5:CURLY{0,1}(9) | 2| EXACT <o> can match 0 times out +of 1... 0 <> <foo> | 3| 9:CLOSE1(11) 0 <> <foo> | 3| 11:WHILEM[1/1](0) | 3| WHILEM: matched 1 out of 0..655 +35 | 3| WHILEM: empty match detected, t +rying continuation... <---- HERE + 0 <> <foo> | 4| 12:NOTHING(13) 0 <> <foo> | 4| 13:END(0) Match successful! Freeing REx: " ( o? )* " D:\tmp>

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery


In reply to Re^4: Is it safe to use external strings for regexes? (infinite loops) by LanX
in thread Is it safe to use external strings for regexes? by stevieb

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2024-04-20 01:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found