Along with Perl, you will need the DBI and DBD modules to write scripts that interact with MySQL. On Windows, with ActivePerl, you can use the Perl Package Manager (PPM) to add the extra DBI and DBD modules. The PPM comes with ActivePerl and simplifies the task of installing CPAN modules. (CPAN, short for Comprehensive Perl Archive Network, is a library of shared code that simplifies common programming tasks.) Despite all of these different tools, the only requirement of the following installation instructions is that you are connected to the Internet as you proceed through them.
Download the most current version of ActivePerl from www.activestate.com
If you are installing ActivePerl on Windows 2000 or XP, you need to download only the Windows Installer Package (an MSI file). Otherwise, you'll see the other requirements for installation when you go through the download steps. At the time of this writing the current version of ActivePerl was 22.214.171.1245.
Run the downloaded executable by double-clicking the file (Figure 8.1
Figure 8.1. The ActivePerl Setup Wizard will take you through the installation of Perl on Windows.
The installer will take you through a few steps, giving you prompts at certain points to help customize the installation. Accepting the default settings will best ensure problem-free operation of ActivePerl.
Do make sure that you install the PPM (Perl Package Manager) on the Setup page (Figure 8.2
Figure 8.2. The PPM (Perl Package Manager) must be installed in order to easily add Perl support for MySQL.
This concludes the installation of ActivePerl on your system. Now you'll need to install the database modules.
Access a DOS prompt.
There are many ways of doing this, including clicking the Start menu, selecting Run, and entering cmd in the box that appears (then pressing Enter).
Test that Perl was successfully installed by entering the following and pressing Enter (Figure 8.3
Figure 8.3. If ActivePerl was installed correctly, you should see a message like this after running perl -v.
The command perl -v
will report on the version of Perl currently installed and running on your system, along with any other pertinent information. This is a simple test of the installation.
At the prompt, type ppm
and press Enter (Figure 8.4
Figure 8.4. The Perl Package Manager simplifies the installation of extra Perl modules.
This command should start up the ActivePerl Perl Package Manager. You'll see a ppm>
prompt once you are within the application.
Install the DBI module by typing this at the prompt and pressing Enter:
PPM will download and install all of the necessary files, reporting on its success (Figure 8.5
Figure 8.5. Using PPM, you should first install the DBI module for general database interactions.
Install the MySQL module for Perl (Figure 8.6
Figure 8.6. To use Perl with the MySQL database in particular, you'll need to install the DBD-MySQL package.
Once the DBI package has been installed, you'll need to install the database-specific modules, such as DBD-MySQL. The Perl scripts will use DBI and DBD-MySQL together to connect to the databases.
Exit out of PPM by typing quit and pressing Enter.