I was wondering if it was possible to call a function inside a Perl here doc
sub Function
{
}
print<<HERE;
Function()
HERE
Do you mean that you want the function's return value to be interpolated into the heredoc?
sub Function {
qw( Hello, World! );
}
print <<HERE;
@{[ Function() ]}
HERE
To explain the syntax, perlmonks says:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With