in reply to heredoc interpolation
Note that you can combine heredocs with other constructs. For example if you are constructing some complex sub amd don't want to backwack everything, but do want to interpolated in one or two places, then you can do something like:
my $code = sprintf <<'EOC', $var1, $var2; sub doSomething { my( $arg1, $arg2 ) = @_; my $result; ... my $var = 2 * %d * %d; ... return $result; }
You can even take that a stage further and use multiple heredocs in one statement.
For example you might use one that doesn't interpolate and another that does:
my $code = sprintf <<'EOD', $a, <<EOD2; my $var = %d; %s my $y = 123455; EOD my \$x x= 1000 * $.; EOD2 print $code; my $var = 0; my $x x= 1000 * 18; my $y = 123455;
|
|---|