>>>>> "chatiman" == chatiman  <[EMAIL PROTECTED]> writes:

chatiman> Is it possible to access the program variables from perl template code([%
chatiman> PERL %] blocks ).

Yes.  Examples are provided on the Template::Manual::Directives
manpage, but you may have to understand a bit about the context and
the stash, documented at Template::Context and Template::Stash,
respectively (as it says there):

       PERL
           (for the advanced reader)

           The PERL directive is used to mark the start of a
           block which contains Perl code for evaluation.  The
           EVAL_PERL option must be enabled for Perl code to be
           evaluated or a 'perl' exception will be thrown with
           the message 'EVAL_PERL not set'.

           Perl code is evaluated in the Template::Perl package.
           The $context package variable contains a reference to
           the current Template::Context object.  This can be
           used to access the functionality of the Template
           Toolkit to process other templates, load plugins, fil-
           ters, etc.  See Template::Context for further details.

               [% PERL %]
                  print $context->include('myfile');
               [% END %]

           The $stash variable contains a reference to the top-
           level stash object which manages template variables.
           Through this, variable values can be retrieved and
           updated.  See Template::Stash for further details.

               [% PERL %]
                  $stash->set(foo => 'bar');
                  print "foo value: ", $stash->get('foo');
               [% END %]

           Output
               foo value: bar


-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

_______________________________________________
templates mailing list
[EMAIL PROTECTED]
http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to