[SP-pm] Inserindo variável no pro_process

Daniel de Oliveira Mantovani daniel.oliveira.mantovani at gmail.com
Fri Dec 12 09:38:10 PST 2008


Minha dúvida é a seguinte, eu tenho um arquivo que chama head.info:
<code>

1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
2<html>
3<head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
5  <link rel="stylesheet" href="../style.css" />
6 <title>[% title %]</title>
7 </head>

</code>
Na linha 7 eu quero por o título, mas não sei como faço isso incluindo uma
variável em um pré processo, olha meu código:
<code>

 1 #!/usr/bin/perl
  2
  3 BEGIN {
  4     my $homedir = ( getpwuid($>) )[7];
  5     my @user_include;
  6     foreach my $path (@INC) {
  7         if ( -d $homedir . '/perl' . $path ) {
  8             push @user_include, $homedir . '/perl' . $path;
  9         }
 10     }
 11     unshift @INC, @user_include;
 12 }
 13
 14
 15 use strict;
 16 use warnings;
 17 use Template;
 18 use CGI qw/ :standard/;
 19
 20 # some useful options (see below for full list)
 21 my $config = {
 22 INCLUDE_PATH => '/home/redrosec/public_html/cgi-bin/',  # or list ref
 23 INTERPOLATE  => 1,   # expand "$var" in plain text
 24 POST_CHOMP   => 1,   # cleanup whitespace
 25 PRE_PROCESS  => 'header.info',# prefix each template
 26 EVAL_PERL=> 1,   # evaluate Perl code blocks
 27 };
 28
 29
 30 my $vars = {
 31    'title' => "Hello World"
 32 };
 33 # create Template object
 34 my $template = Template->new($config, $vars);
 35
 36 # specify input filename, or file handle, text reference, etc.
 37 my $input = 'begin.tt';
 38
 39 # process input template, substituting variables
 40 $template->process($input) || die $template->error();
 41
 42 print<<'GOOGLE';
 43 <p align=center>
 44 <script type="text/javascript"><!--
 45 google_ad_client = "pub-6551982862465531";
 46 /* 728x90, criado 04/12/08 */

34,29      Início
</code>

Eu quero inserir a variável na linha 31, dentro do header.info e não tenho
ideia de como fazer.
-- 
Procuro emprego C.V:
http://danielmantovani.awardspace.com/

print
"\x54\x68\x65\x20\x53\x69\x6c\x65\x6e\x74\x20\x47\x75\x61\x72\x64\x69\x61\x6e",$/
-------------- Pr?xima Parte ----------
Um anexo em HTML foi limpo...
URL: <http://mail.pm.org/pipermail/saopaulo-pm/attachments/20081212/9f582750/attachment.html>


More information about the SaoPaulo-pm mailing list