in reply to Re(6): Regex Capturing: Is this a bug or a feature?
in thread Regex Capturing: Is this a bug or a feature?

If local() doesn't work that way, why does this example localize every time through the block?

What? When did I start disagreeing on how local() works? I even said "Otherwise you'd do the thing [= local()ization] on each iteration of the block". The whole point of doing the local()ization outside the block is to circumvent the relocal()ization -- because you don't want the relocal()ization. With the relocal()ization it wouldn't be equivalent to what perl does with the regex-variables. Again, I'm trying to manually do what Perl does for you.

There seems to be a lot of confusion here. It all started with me stating how I'd interpret how perl works in pure-Perl. That was because if you know Perl you also understand the behaviour you can deduce from the code. So if you saw a "picture" of how it works it could help you (and other reading this) to remember the behaviour.

I know that the regex-variables are highly magical and I don't really understand how they work internally myself. My interpretation comes from the documentation, and I can't recall me having any other interpretation of it. I've always pictured me the regex-variables working something like what I wrote above, and it seems like it works alright. I haven't found any occation where my picture gives the wrong results -- but I haven't look so I don't claim it to be perfect.

-Anomo

Replies are listed 'Best First'.
Re: Re: Re(6): Regex Capturing: Is this a bug or a feature?
by shotgunefx (Parson) on Sep 30, 2002 at 22:30 UTC
    I think the confusion resulted from this statement.
    What's declared in that block? Something is declared for the block rather than in it.

    I have no problem remembering the behavoir now that I'm aware of it, my issue is that I've never read anything that would indicate it would work that way. Everything I've read says "Dynamic scoping" which is often used interchangably with local().
    Elian has a good explanation of what's going on under the magic carpet here

    -Lee

    "To be civilized is to deny one's nature."