perlfaq nodetype
faq_monk
<P>
This is documented in [perlman:perlref|the perlref manpage]. In general, this is fraught with quoting and readability problems, but it
is possible. To interpolate a subroutine call (in list context) into a
string:
<P>
<PRE> print "My sub returned @{[mysub(1,2,3)]} that time.\n";
</PRE>
<P>
If you prefer scalar context, similar chicanery is also useful for
arbitrary expressions:
<P>
<PRE> print "That yields ${\($n + 5)} widgets\n";
</PRE>
<P>
Version 5.004 of Perl had a bug that gave list context to the expression in <CODE>${...}</CODE>, but this is fixed in version 5.005.
<P>
See also ``How can
<FONT SIZE=-1>I</FONT> expand variables in text strings?'' in this section of the
<FONT SIZE=-1>FAQ.</FONT>
<P>