Sep 13, 2012

HTML::Template example 1 in MVC

template1.cgi
############
    #!c:/perl/bin/perl  
      use CGI qw(:all);  
      use HTML::Template;  
      use POSIX;
     
      my $q = CGI->new;
      print $q->header();
     
      my $template = HTML::Template->new(filename => 'template1.tmpl');
      $template->param(day => strftime('%A', localtime()) );
      print $template->output(); 

template1.html
################
<html>  
<head>  
  <title>Template 1</title>  
</head>  
<body>  
Today is <tmpl_var name=day>  
</body>  
</html> 

No comments:

Post a Comment