in reply to string manipulation question

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.


--
g r i n d e r

Replies are listed 'Best First'.
Re: Re: string manipulation question
by Anonymous Monk on May 18, 2001 at 18:58 UTC
    for instance do the newlinine in the ref
    my $str = <<FOO; a load of constant stuff...@{[ "optional bit in the middle " if defined $option ]}loads more stuff FOO