While playing around with HTML::Template, I found a nice behavior, which is problably documentented, but I haven't found it.
If you run this code
it prints out:# the template is just <TMPL_VAR NAME="hallo"> use HTML::Template; use strict; my $t=new HTML::Template( filename => "/tmp/tmpl"); print "3 ".time()."\n"; $t->param( "hallo" => \&littletest ); sleep 3; print "2 ".time()."\n"; sleep 3; print $t->output; sub littletest { print "1 ".time()."\n"; return "test"; }
But if you change the referenced sub to just the sub (delete the \), it prints out:3 1019119182 2 1019119185 1 1019119188 test
3 1019119294 1 1019119294 2 1019119297 test
This allows you to setup parameters which will be evaluated
at print time instead of assignment time.
If this isn't a new feature, well than I am just proud to
have found a documented feature myself :-)
---------------------------
Dr. Mark Ceulemans
Senior Consultant
IT Masters, Belgium
In reply to Nice HTML::Template feature by mce
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |