Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^4: Converting multiple spaces to nbsp

by Smylers (Pilgrim)
on Jun 17, 2005 at 15:17 UTC ( [id://467761]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Converting multiple spaces to nbsp
in thread Converting multiple spaces to nbsp

oo! That's unexpected! I didn't realize that the previous substitution failed to affect ...

If you think about it, it has to be that way: otherwise you could end up subsituting out something that you've just put in there earlier in the same subtitution, and something like s/und/underground/g would get stuck in an infinite loop.

But it doesn't matter whether using the already-replaced text would enable further substitutions or prevent existing ones; in neither case is it taken into account.

Smylers

Replies are listed 'Best First'.
Re^5: Converting multiple spaces to nbsp
by ikegami (Patriarch) on Jun 17, 2005 at 15:27 UTC
    something like s/und/underground/g would get stuck in an infinite loop.

    No, because the position variable changes. For in-place substitution, it would move by length('underground'). Otherwise, it would move by length('und').

    I made the assumption that the substitution was done in place (since the syntax seems to imply it). You've shown me that's not the case, but it could have been written that way. (Although magic variables would need to be treated specially.)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://467761]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-04-23 07:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found