Vorrei utilizzare il modulo HTML :: Template. Tuttavia, non è installato sul server che sto usando per sviluppare script CGI.Come posso caricare un modulo Perl in fase di runtime?
E 'possibile caricare un modulo in fase di esecuzione: ho trovato il file Template.pm sulla mia installazione Perl locale e ho caricato il file sul server che sto 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;
Sono confuso. Se hai caricato Template.pm sul tuo server, dovresti riuscire a caricarlo in fase di compilazione con 'use'? – rjh
Ho ricevuto un errore sulla linea: my $ template = HTML :: Template-> new (filename => 'test.tmpl'); – coson
@coson E qual è l'errore? –