in reply to Calling a function from within a HERE doc?

You can do this, as well as interpolation in more normal double-quoted strings, with the module Interpolation, originally written by dominus as a joke, currently maintained by Jenda.

I don't like the import interface, I think you should just call a tie a tie, but you can just use tie with the module without any changes.

use Interpolation; tie my %EVAL, Interpolation => 'eval'; # or: tie my %EVAL, Interpolation => sub { shift }; print <<"END"; The sum of 3 and 4 is $EVAL{3+4}. END
(Be sure to have at least one more line under "END")

The key to how this works is that an index to a hash or an array is always interpreted as perl code. Next, a tied hash is used to execute an associated function, instead of actually fetching a hash value out of somewhere.