Bug in HTML::Template? What are you talking about?
No offense, but something tells me that you are overlooking
something on your side and you are thinking that it is a bug in that module (at the most i wager it's a feature that
samtregar never intended HTML::Template to do).
Abigail-II's solution is right on ... nobody says
that you ever need use the <> operator to pass a
package's DATA filehandle around (and it is
filehandle by the way, not filehandler ... you aren't
handling a file, you are getting a handle on the
file). Here is some code to demonstrate:
We call a package's (Foo) subroutine which returns an
object to us (Bar). Bar contains one 'attribute' whose value
is a reference to Foo's DATA filehandle. Back
inside main we instantiate a new HTML::Template
and pass Bar's 'filehandle' it to (which is really a
reference to Foo's). We then pass it a param for it to
substitute and then we print the output. Here goes:
use strict;
use warnings;
use HTML::Template;
my $bar = Foo::do_it();
my $tmpl = HTML::Template->new(filehandle => $bar->{filehandle});
$tmpl->param(baz => 'Hello GLOB!');
print $tmpl->output();
package Bar;
sub new {
my $class = shift;
return bless {@_}, $class;
}
package Foo;
sub do_it {
my $bar = Bar->new(filehandle => \*DATA);
return $bar;
}
__DATA__
<html>
<body>
<h1><tmpl_var baz></h1>
</body>
</html>
Finally note, i tend to use DATA only for tests
and example scripts - i avoid it when it comes to writing
real production code. Use seperate files instead. I guess
if you have each page associated with one and only one
module it would make sense ... but i tend to associate
multiple pages with each module (add, edit, view, delete,
list all, etc.) ... Inline::Files? Nah! ;)
Best of luck to you and please let us
know how your progress goes. :)
jeffa
L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)
| [reply] [d/l] |