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

The code above is stripped down to an example. I do find this behaviour quite suprising and very NWIM. I would go so far to say that it's documentated incorrectly (at the very least, poorly). Both are described as dynamic scoping.

Looking at perlsub and local() This is known as dynamic scoping. Lexical scoping is ...

-Lee

"To be civilized is to deny one's nature."
  • Comment on Re: Re: Regex Capturing: Is this a bug or a feature?

Replies are listed 'Best First'.
Re: Re: Re: Regex Capturing: Is this a bug or a feature?
by fruiture (Curate) on Sep 28, 2002 at 15:22 UTC

    Well, the documentation doesn't say they're scoped like "local" would do :-)

    In a way you're right, but imho there is no problem arising from this issue if you always use your own variables instead of $1 .. $n. (Which means you assign your own vars immediately after the match).

    --
    http://fruiture.de
      Well there is no problem if and ONLY if you conditionally assign based on the match.

      I'm not complaining about how it works, more about how it's documented. dynamic and local() are equated many times in the perlpods.

      -Lee

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