Interpolate the optional bit via a code reference @{[ ... ]} .
my $str = <<FOO; a load of constant stuff... @{["optional bit in the middle " if defined $option]} loads more stuff FOO
Beware that as this example stands, you'll get a newline regardless of whether $option is defined or not, but I'm sure you can figure out how to make it do The Right Thing.
In reply to Re: string manipulation question
by grinder
in thread string manipulation question
by iakobski
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |