Is there not a way to run arbitrary code and interpolate the result as
a literal string (instead of a Regex)?
I assume that {...} is intended to be where you hook in
semantics/actions mid-parse, but it seems a bit counter-intuitive that
the same syntax interpolates in double-quote context but not regexes.
Question Inspired by this Rakudo patch:
On Monday, March 29, 2010, Bruce Keeler <[email protected]> wrote:
> # New Ticket Created by Bruce Keeler
> # Please include the string: [perl #73862]
> # in the subject line of all future correspondence about this issue.
> # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=73862 >
>
>
> The attached patch adds support for variable and block-result
> interpolation into regexes.
>
> It does so by means of a new PAST::Regex node pasttype 'interpolator'.
> The following syntaxes are supported by this patch:
>
> / $var / -- Interpolates as literal string, unless it's a Regex object
> / @foo / -- Interpolated as ||-style alternations of literal strings
> or Regex objects
> / <$var> / -- compiled into a Regex (unless it's already one), then
> interpolated
> / <@foo> / -- A list of ||-style alternations of things to be
> compiled into Regexes (unless they already are)
> / <{ ... }> / -- Result of capture is interpolated as a Regex,
> compiling if necessary
> / <?{ ... }> / -- Unchanged
> / { ... } / -- Capture is merely executed, but not interpolated.
> (Unchanged)
>
--
Mark J. Reed <[email protected]>