John Macdonald wrote:
The problem with "interpolate if you can or leave it alone for later" is that when later comes around you're in a quandry. Is the string "$var" that is in the final result there because it was "$var" in the original and couldn't be interpolated, or was it a $foo that had its value of "$var" injected into its place?
The "maybe do it now, finish up later what wasn't done the first round" approach runs the risk of double interpolation. (Or single interpolation, or non-interpolation, whichever it happened to roll on the dice.) If you're Randal Schwartz discovering a
s/Old Macdonald/$had a $farm/eieio
accidental feature, that can be useful; but for mere portals,
it is just a bug waiting to surface.
Maybe this should be the default behavior.
my $nameRight = "name"; my $nameWrong = "other name";
print "$nameRight != $name_wrong\n";
name != $name_wrong
I wonder where my mistake is?
This looks like a decent win for PEBKAC errors. Maybe this should go on by default if the "I need help" flag is turned on.
OTOH, I don't have much use for the original proposal because I also want to be able to defer interpolation of variables that DO exist, like $!.
I like the idea of defining a secondary interpolation character, or perhaps a secondary escape character.
my $name = "defined now, but it will change later"; my $output_text = <<EOF:esc('`'); $template_header
`$name
$template_footer EOF
=Austin