in reply to HTML::Template in a module's __DATA__ section

The chief confusion for me is why you don't consistently get the error message. The error message is correctly complaining about your code. You don't have a definition for variable 'VALUE' and so the error message is saying something is wrong with the statement.

I can't seem to provoke the error message even when using your code. It works in both versions, well, after I put the "Foo->run();" statement into the second version. Otherwise your second version outputs nothing.

This is the code I was playing with:

#!/usr/bin/perl use strict; use warnings; Foo->run(); package Foo; use HTML::Template; sub run { my @html = <DATA>; my $template = HTML::Template->new( arrayref => \@html, strict => 1, + die_on_bad_params => 1 ); $template->param( VALUE => 'pick me - pick me!' ); print $template->output; } 1; __DATA__ <html> <head> </head> <body> <TMPL_VAR NAME=VALUE> </body> </html>
which outputs
<html> <head> </head> <body> pick me - pick me! </body> </html>
You might also want to upgrade to version 2.7. It is a couple years newer than the version 2.6 that you are running (but forgot to mention)

Replies are listed 'Best First'.
Re^2: HTML::Template in a module's __DATA__ section
by Anonymous Monk on Sep 12, 2004 at 01:46 UTC
    Yay, thanks!

    The version was the problem. I pasted in your posted code, and it gave an error too, so I hit CPAN for an upgrade and viola, it worked. I didn't even think of an error in HTML::Template.

    As to why I don't get an error message in the original, not providing a substitution value is not an error, it just swaps out the value with an empty string.

    Thanks again, you guys rock.