I recently stumbled across DBM::Deep, which is very cool in itself, but moments ago it occurred to me that this could easily make a nice arbitrary shared data storage for Template templates. Yes, I said shared. Unlike MLDBM, this can be used safely with multiple processes. It's like magic. And, it's a single Pure-perl PM file, so you can install it on shared hosting solutions for CGI stuff.

Beware: Template considers this to be a blessed object, you can't call normal hash or array vmethods. However, you can call the export method on any part of the tree to get a normal unassociated data structure, which can then be used with normal vmethods.


UPDATE: I've just uploaded Template::Plugin::DBM::Deep to get at all of this directly from Template, rather than having to create the structure externally. Woo hoo.
Perl:
use DBM::Deep; use Template; my $t = Template->new(); # create engine my $db = DBM::Deep->new( file => "foo.db", locking => 1, autoflush => 1, ); # create storage ... $t->process($your_template, { db => $db });
In the template:
[% db.foo = { fred => 3 barney => 2 }; # make permanent addition db.foo.fred; # get "3" %]