in reply to Re: reinterpolation of regexp (and strings?)
in thread reinterpolation of regexp (and strings?)

Tricky. I don't think you can do it without the eval. Unless the /ee option does the trick as ikegami suggests.

s/.../.../ee is short for s/.../eval .../e, so that "unless" is not an exception.

Your suggestion of re-interpolation sounds nice but is probably very tricky to implement.

It's not possible since interpolation involved executing arbitrary code. Maybe a limited form of interpolation? That would be possible and useful.

Replies are listed 'Best First'.
Re^3: reinterpolation of regexp (and strings?)
by massa (Hermit) on Jul 23, 2008 at 09:30 UTC
    Are you aware that _any_ string interpolation can inject _any_ arbitrary code in a string? Try this:
    perl -le 'print qq(@{[ do{ print q(I got here first); 1 } ]})'
    The thing is: there is no safe string interpolation, you you might as well do the //ee thingy. :-)
    []s, HTH, Massa (κς,πμ,πλ)

      Are you aware that _any_ string interpolation can inject _any_ arbitrary code in a string?

      Yes, I know since I said as much in the post to which you replied.

      Are you aware that _any_ string interpolation can inject _any_ arbitrary code in a string?

      Not true. The one provided by String::Interpolate doesn't.

      The native interpolation mechanism does, but we were never talking about that. The OP was proposing a new feature. While I don't see anyone putting in the effort into implementing what is really just another template system, I mentioned that interpolation is not necessarily unsafe, only the current native implementation, and that a safe implementation could be devised.