Brad Bowman asked:
When building code strings in Perl 5 I usually write the code,
then wrap it in double quotes, then "\" escape everything light blue
under syntax highlighting. I was wondering if there'll a better
way in Perl 6.
I thought it would be nice to define the variables you wish to
interpolate individually, perhaps as extensions to the :s, :a,
etc quote adverbs, perhaps using a signature object.
There is already a mechanism for this. You simply turn off all variable
interpolation, and interpolate any the variables you wish to interpolate via
block interpolations. Or, more simply, only turn on block interpolation in a
non-interpolating string:
my $code = q:c{
package {$package_name};
sub {$sub_name} \{
return {$return_val}
\}
};
Damian