Databases Reference
In-Depth Information
# perl -MCPAN -e 'install DBI'
# perl -MCPAN -e 'install DBD::mysql;'
# perl -MCPAN -e 'install CGI;'
If this is the first time you're installing Perl modules this way, you may be prompted to
answer a few questions. It's generally safe to answer no to the question:
Are you ready for manual configuration? [yes]
and leave it to Perl to figure out how to fetch the required packages. If all goes well,
you should see reassuring status messages as Perl downloads and installs everything.
Perl modules are also available for individual Linux distributions, and you can down-
load and install them manually. For RPM-based systems, you should download and
install the perl-DBI package for DBI, the perl-DBD-mysql package for the DBI MySQL
driver, and the perl-CGI package for CGI. For example, on a Red Hat or Fedora system,
type:
# yum update perl-DBI perl-DBD-mysql perl-CGI
For a Mandriva or Mandrake system, type:
# urpmi perl-DBI perl-DBD-mysql perl-CGI
For a Debian-based system, the package names are slightly different:
# apt-get install libdbi-perl libdbd-mysql-perl libcgi-pm-perl
Installing Perl modules under Windows
Windows does not have Perl support by default, so you need to install a Perl interpreter
yourself. The XAMPP package you installed earlier in this chapter includes a minimal
Perl setup. However, to include a reasonable set of Perl libraries, including the DBI and
CGI modules and the MySQL DBD, you should also visit the web page http://www
.apachefriends.org/en/xampp.html and download and install the Perl Addons installer.
This will have a filename similar to xampp-perl-addon-5.8.7-2.2.2-installer.exe . Install
this in the same directory in which your XAMPP installation is located; we assume this
is C:\Program Files\xampp .
Many of the MySQL command-line programs in the scripts directory are in fact Perl
scripts; if you want to use these scripts, you'll need to associate Perl files with the Perl
interpreter. To do this, you tell Windows that all files with the standard Perl exten-
sion .pl must be run by the Perl interpreter. Open a command prompt window and
type the following two lines:
C:\> ASSOC .pl=PerlScript
C:\> FTYPE PerlScript=C:\Program Files\xampp\perl\bin\perl.exe %1 %*
You can now run Perl scripts by double-clicking on the icon of the script file, or by
typing in the name of the script file at the command prompt. You can find other tips
for using Perl under Windows in the Perl Win32 FAQ ( http://www.perl.com/doc/FAQs/
nt/perlwin32faq4.html ).
 
Search WWH ::




Custom Search