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

You can do it.... with variable interpolation!
print <<HERE; This is a string. Here's some more. The time is currently: @{[ scalar localtime() ]} HERE
The @{} interpolates an array into your here-doc, and the inner [] creates an anonymous array, whose elements consist of whatever expression(s) you want to put between them.