Quite often companies who use Catalyst (with Template Toolkit) find that after a while, they're over relying on the use of the stash as a global dumping ground. To deal with that, I wrote a highly experimental module to print out unused template variables.

It works like this:

my $template = Template->new({ STASH => Template::Stash::Unused->new({ template_dir => 'root', debug_level => 1 }) });

When the stash goes out of scope, it dumps to STDERR a report which looks like this:

# Stash variable 'customers' unused, but found in templates # Stash variable 'orders' unused, but found in templates # Stash variable 'item_count' unused, but found in templates # Stash variable 'products' not found in root/

With Catalyst, you would use it like this:

package Veure::View::HTML; use Modern::Perl; use Template::Stash::Unused; use parent 'Catalyst::View::TT'; __PACKAGE__->config( TEMPLATE_EXTENSION => '.tt', WRAPPER => 'site/wrapper', EVAL_PERL => $Veure::DEBUG, ENCODING => 'utf-8', PLUGIN_BASE => 'Veure::Template::Plugin', STASH => Template::Stash::Unused->new({ template_dir => 'root', debug_level => 1, }), );

It's fairly naïve in it's approach, but so far for one $client I'm finding plenty of unused variables that we can delete from our code (note that it only works on Unix like systems because it calls out to the shell).