On Thu, Feb 14, 2002 at 11:54:58AM +0100, Gernot Homma wrote:
> so how can i access the constants.

You need to create template variables which reference those constant
subroutines.  For example:

  package MyPack;
  use constant pi => 3.14;
  use constant e  => 2.718;

  package main;
  use Template;

  my $tt = Template->new();
  my $vars = {
      pi => \&MyPack::pi,
      e  => \&MyPack::e,
  };

  $tt->process(\*DATA, $vars)
      || die $tt->error, "\n";

  __DATA__
  pi: [% pi %]
   e: [% e %]
        
HTH
A




Reply via email to