Search code examples
perlreportreporting

How to check variable type in template toolkit?


Is there any statement to print variable type in Template Toolkit? This is for debugging purposes. I was trying to find something like:

type(my_var)

Output:

scalar

Solution

  • Use the PERL directive. Example:

    [% PERL %]
       print "my_var type: ", ref( $stash->get('my_var') ) || 'scalar';
    [% END %]