Setting up Perl

Chapters 16, 17, and 18 require that you have a working installation of Perl. Perl is available as standard on almost all Linux and Mac OS X systems, and it is included in the XAMPP integrated package, so you don’t need to install it separately. For Chapters 17 and 18, you’ll need two Perl extension packages or modules. We’ll use the Perl DBI (Database Interface) module in Chapter 17 to talk to a MySQL server, and the Perl CGI (Common Gateway Interface) module in Chapter 18 to write clean and readable scripts that can be run by a web server. If you’re not planning to write complex Perl scripts for a web application, you can manage without the CGI module, but you’ll definitely need the DBI module to use Perl for interaction with MySQL.

Checking Your Existing Setup

To run Perl scripts, you need to know where the Perl interpreter (called perl) is installed on your system. For Linux, we’ll use the instance of Perl that comes with the distribution; to find where this is located, use the which command:

$ which perl
/usr/bin/perl

In this example, the Perl interpreter is the file /usr/bin/perl.

For Windows and Mac OS X systems, we’ll use the instance of Perl that comes with XAMPP. On a Windows system, the XAMPP Perl interpreter is C:\Program Files\xampp\perl\bin\perl.exe, while on a Mac OS X system, the XAMPP Perl interpreter is /Applications/xampp/xamppfiles/bin/perl. You can also use the Mac OS X system default installation (/usr/bin/perl), but as we discuss later in Installing ...

Get Learning MySQL now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.