Me gustaría utilizar el módulo HTML :: Plantilla. Sin embargo, no está instalado en el servidor que estoy usando para desarrollar scripts CGI.¿Cómo puedo cargar un módulo Perl en tiempo de ejecución?
Es posible cargar un módulo en tiempo de ejecución: Encontré el archivo Template.pm en mi instalación local de Perl y cargué el archivo en el servidor que estoy usando.
#!/usr/bin/perl -w
use CGI qw(:standard :html4);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
# use HTML::Template;
use Template;
# my $package = "HTML::Template";
# eval {
# (my $pkg = $package) =~ s|::|/|g; # require need a path
# require "$pkg.pm";
# import $package;
# };
# die [email protected] if([email protected]);
# open the HTML template
my $template = HTML::Template->new(filename => 'test.tmpl');
# fill in some parameters in the template
$template->param(home => $ENV{HOME});
$template->param(path => $ENV{PATH});
# send the obligatory Content-Type
print "Content-Type: text/html\n\n";
# print the template
print $template->output;
Estoy confundido. Si ha cargado Template.pm en su servidor, ¿debería poder cargarlo en tiempo de compilación con 'use'? – rjh
Recibo un error en la línea: my $ template = HTML :: Template-> new (filename => 'test.tmpl'); – coson
@coson Y, ¿cuál es el error? –