Subject: | Can't check defined values while under STRICT |
I'm running under STRICT, I'm passing Moose objects into my template, I want to make decisions based on whether an attribute is defined.
I can't/shouldn't assume the object is a hash and that the keys match the method names, so obj.defined('method') is out, I tried obj.method.defined but this throws.
Below is example code demonstrating the issue:
package Foo;
sub new { bless [] }
sub bar {
warn "->bar called\n";
return;
}
package main;
use Template;
my $tt = Template->new( STRICT => 1 );
$tt->process(
\'[% "It works" IF foo.bar.defined %]',
{ foo => Foo->new },
) or die $tt->error;
I'm not sure if this is a bug or wishlist, but I can't for the life of me see a way to use STRICT without this fixed/added.