Databases Reference
In-Depth Information
You should either add this bin directory to your system path following the instructions
earlier in this chapter in “Error Message About MySQL Executable Programs Not Being
Found or Recognized,” or specify the full path to the Perl interpreter whenever you see
perl for the remainder of this chapter.
If Perl is available, the command will display several lines of text describing the version
and other configuration details. If Perl is not installed, you'll see an error message saying
something like command not found (Linux or Mac OS X) or 'perl' is not recognized
as an internal or external command, operable program or batch file (Windows).
You can find more information on obtaining and installing Perl at http://www.perl.org/
get.html , and more information on installing modules at http://www.cpan.org/modules/
INSTALL.html . For a Linux system, download and install the Perl package for your
distribution according to the instructions in “Installing MySQL, Apache, PHP, and Perl
on Linux Using Distribution Packages.” For a Windows or Mac OS X system, check
that you've installed XAMPP correctly.
Once you know that Perl is installed, you can test whether the DBI and CGI modules
are installed by asking the Perl interpreter to use these modules to run an empty Perl
script. To check whether the DBI module is installed, type:
$ perl -mDBI -e ''
If you see an error message that Perl “Can't locate” DBI.pm , you'll need to install the
module yourself. Similarly, check whether the CGI module is installed by typing:
$ perl -mCGI -e ''
If the DBI module is installed, you should also check whether the MySQL database
driver (DBD) is installed. An easy way to do this is to ask Perl to print out all the drivers
that are available:
$ perl -e "use DBI; foreach $d (DBI->available_drivers()){print $d;}"
DBMExamplePFileSpongemysql
If you don't see the letters “mysql”, you'll need to install the MySQL database driver.
Installing the Perl DBI and CGI Modules
If you found that you need to install the CGI or DBI module, or the MySQL DBD, then
you need to follow the steps outlined in the following sections for each operating
system.
Installing Perl modules under Linux
The standard way to install Perl modules is to get Perl to use the CPAN (Comprehensive
Perl Archive Network) module to install new modules from the Internet. Log in as the
system root user by typing su - , and then install the DBI module, the DBI MySQL
Database Driver, and the CGI module by running the following commands in turn:
 
Search WWH ::




Custom Search