"be consistent" | |
PerlMonks |
Re: sub return value in qq{}by davido (Cardinal) |
on Nov 02, 2022 at 14:16 UTC ( [id://11147919]=note: print w/replies, xml ) | Need Help?? |
The dereferenced arrayref technique works fine: "a string @{[foo()]}\n". But it's a little magical; it requires some tribal knowledge or testing for a reader of the code to understand what is happening. Perl also provides printf, which is well documented and should be clearer for a reader:
Additionally, there are a lot of template systems available to Perl. Template::Toolkit, Text::Template, Mojo::Template, Template::Tiny, and many others. Here is an example using Template::Toolkit:
This code works as-is with Template::Tiny if you just replace any mention of Template with Template::Tiny. Dave
In Section
Seekers of Perl Wisdom
|
|