有关详细信息,请参阅此Example
use strict; use warnings;
use CGI::Simple;
use DBI;
my $cgi = CGI::Simple->new;
my $dsn = sprintf(
'DBI:mysql:database=%s;host=%s',
'cdcol', 'localhost'
);
my $dbh = DBI->connect($dsn, root => '',
{ AutoCommit => 0, RaiseError => 0 }
);
my $status = $dbh ? 'Connected' : 'Failed to connect';
print $cgi->header, <<HTML;
<!DOCTYPE HTML>
<html>
<head><title>Test</title></head>
<body>
<h1>Perl CGI Script</h1>
<p>$status</p>
</body>
</html>
HTML
这段代码给了我错误:
The server encountered an internal error and was unable to complete your request. Error message: Can't locate CGI/Simple.pm in @INC (@INC contains: C:/xampp/perl/site/lib/ C:/xampp/perl/lib C:/xampp/perl/site/lib C:/xampp/apache) at C:/xampp/htdocs/perl/index.pl line 4. BEGIN failed--compilation aborted at C:/xampp/htdocs/perl/index.pl line 4. , Error 500 localhost 3/25/2010 11:19:19 AM Apache/2.2.14 (Win32) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l mod_autoindex_color PHP/5.3.1 mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1
这是什么意思,我该如何解决?
答案 0 :(得分:2)
AFAIK,xampp是基于ActivePerl的。在命令行中键入ppm install CGI-Simple
。
ppm install DBD-mysql
也是一个好主意。
答案 1 :(得分:1)
将您的脚本转换为使用CGI.pm而不是CGI::Simple,或者使用CGI::Simple
或ppm
安装cpan
。