in reply to Re: How to use Perl in HTML Template?
in thread How to use Perl in HTML Template?

Thanks Monks for reply and it's working. Now i change the file a little more and got message "Error:EVAL_PERL not set". Could you tell me how to set EVAL_PERL in template . Another issue is that when i run program B it's showing the value of random but in Program A it it not showing the Value of random A.

Program A

[% TRY %] [% PERL %] use WebService::CaptchasDotNet; my $o = WebService::CaptchasDotNet->new(secret => 'secret', username => 'demo'); my $random = $o->random; print "random=", $random; my $url = $o->url($random); print $url; [% END %] [% CATCH %] Error:[% error.info %] [% END %] <html> <title> This is Example of using perl with HTML </title> </html>

Program B

#!/usr/bin/perl use strict; use warnings; use WebService::CaptchasDotNet; my $o = WebService::CaptchasDotNet->new(secret => 'secret', username = +> 'demo'); my $random = $o->random(); print "Random value = ". $random; my $url = $o->url($random);

Replies are listed 'Best First'.
Re^3: How to use Perl in TT2??
by dsheroh (Monsignor) on Nov 03, 2009 at 11:21 UTC
    EVAL_PERL needs to be set (or not - I'd advise against putting non-display logic into your templates) in your call to Template->new. e.g.,
    my $tt = Template->new( INCLUDE_PATH => 'tpl/', TRIM => 1, WRAPPER => 'wrapper.tt', EVAL_PERL => 1, );

    Also, you might want to consider changing your question's title... You're doing this with Template::Toolkit, but there's a different (and unrelated) Perl templating module called HTML::Template. I originally read your question expecting to answer that HTML::Template doesn't support Perl in templates at all.

Re^3: How to use Prel in HTML Template??
by Anonymous Monk on Nov 03, 2009 at 12:08 UTC
    Could you tell me how to set EVAL_PERL in template .

    Please don't do that. Create a Template::Plugin instead