note
Aristotle
No need for [perlfunc:eval|eval] or other heavy artillery.
<code>package TMPL;
sub fodus {
local $/;
my $out = <($main::{+(caller)[0]."::"}->{DATA})>;
# ...
return $out;
}
</code>
The key here is that Perl makes the symbol table of each package available as a hash called <tt>%%packagename::</tt> - with <tt>%main::</tt> containing keys for all packages including itself, the value being a glob pointing in turn to that package's symbol table. So I use <tt>%main::</tt> to get the glob to the caller's package, then dereference it as a hash, fishing the <tt>DATA</tt> key from it in turn.
<p align="right"><em>Makeshifts last the longest.</em></p>
219176
219176