开发者

Why does my Perl CGI script complain about "Can't locate CGI/Simple.pm"?

For more information see this 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,开发者_Go百科 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

This code gives me error:

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 

What does this mean and how can I resolve it?


AFAIK, xampp is ActivePerl-based. Type ppm install CGI-Simple in command line.

ppm install DBD-mysql is also a good idea.


Either convert your script to use CGI.pm instead of CGI::Simple, or install CGI::Simple with ppm or cpan.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜