Subject: | printf() doesn't work in a PERL block |
This code doesn't work:
[% PERL %]
printf "The current timestamp is %d\n", time();
[% END %]
When tested using
echo -e '[% PERL %]\nprintf("Hello %d\n", 42);[% END %]' | tpage --eval_perl
I get this error:
undef error - Can't locate object method "PRINTF" via package "Template::TieString" at (eval 5) line 3, <STDIN> line 1.
It seems the PERLOUT filehandle is tied to a Template::TieString object, and that class doesn't implement the PRINTF method.
A workaround is using print(sprintf(...)) instead of just printf(...).