package MyHungryHippo; use strict; use warnings; use 5.16.0; use base qw[Template::Plugin]; sub new { my ($class, $context) = @_; return bless { _context => $context }, $class; } sub nomnom { my $self = shift; return 'eat it'; } 1; package main; use strict; use warnings; use 5.16.0; use Test::More; use_ok 'MyHungryHippo'; use_ok 'Template'; ok my $tt = Template->new({ PLUGINS => { 'HIPPO' => 'MyHungryHippo' } }); die $tt->error if $tt->error; ok my $tmpl = join('', ); ok my $output = $tt->context->process( \$tmpl, {} ); like $output, qr/eat/ or diag $output; done_testing(); __DATA__ [% USE HIPPO %] [%- HIPPO.nomnom() -%]