in reply to Templating algorithm - pass in variables vs callback?

In template toolkit:
my $lazy = do { my $result; sub { unless (defined $result) { ... do expensive computation ... ... assigning to $result ... } return $result; }; }; my %vars = { lazy => $lazy, easy => 2 + 2, }; $template->process('mything.tt', \%vars);
From the template, you use both "lazy" and "easy" the same way. Except that "lazy" is a coderef. That's what's cool about TT: the call is the same.

I seem to recall a module that does this for you. Yes, Data::Lazy.

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.