How do I specify a conditional parameter in HTML::Template::Pro?
I'm writing it this way but it's causing my program to abort:
HTML::Template::Pro->new(filename=>$file, filter => $filter ? $filter : undef);
What's wrong in the above code?
Basically I want the condition开发者_StackOverflow社区al filter to do encode_entities()
on each TMPL_VAR
.
undef
is not a valid value for filter
. Instead, omit the filter parameter altogether, like this:
HTML::Template::Pro->new(filename=>$file, $filter ? (filter => $filter) : ());
精彩评论