in reply to Re: use of constants in regex substitutions?
in thread use of constants in regex substitutions?

That won't work, because the /e modifier only applies to the second part of the substitution (i.e. the 'substitute with...' part). The first part of the regex follows normal string-interpolation rules, and "&sub" is NOT interpolated in a string any more than "sub" is. This regexp looks for the literal text '&TXT_EXTENSION', and substitutes it with '.mif'.

See Zazo's reply for a correct answer.

--
3dan

  • Comment on Re: Re: use of constants in regex substitutions?

Replies are listed 'Best First'.
Re: Re: Re: use of constants in regex substitutions?
by dmitri (Priest) on Sep 23, 2003 at 13:59 UTC
    You're right; I should've tested first. How come &sub is interpolated when using arrow operator?
    &sub => "xyz";
    AFAIK, this is equivalent to
    "&sub", "xyz";

      Well, I believe the => operator forces a bareword to its left to be interpreted as a string. But &sub isn't a bareword it's a subroutine call, so it works like you want it to. At least, this is my understanding. Hopefully someone will correct me if I'm wrong.

      --
      3dan