2
votes

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, 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?

2
You don't even get to the DBI parts. The answer to this question is found in several places on Stackoverflow.brian d foy

2 Answers

2
votes

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

ppm install DBD-mysql is also a good idea.

1
votes

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