Learning Tree Course 431 - Introduction to Perl Programming: Hands-On

Recommended Books

These are the books I tend to bring into the class: readinglist.html.

Sample Code

Environment Variables CGI

This CGI (Common Gateway Interface) script simply prints out the operating system environment variables. There are two versions. The first uses no external libraries and demonstrates how simple this is. The second uses the CGI module from the perl standard libraries and demonstrates how expressive this can be. The CGI module provides many more facilities than I've shown below.

Basic Version: CGI | Source Code

CGI.pm Version: CGI | Source Code

Database Query

This is a very simple script that demonstrates how you can connect to a database and retrieve data. This is the simplest demonstration of DBI.

dbsel.pl

Command Line Arguments

This script demonstrates how you might use Getopt::Long to process command line arguments. It allows the user to enter two numbers and an operation either as an argument (--add for example) or as the parameter to an argument (--operation=add for example). It the performs some basic arithmetic after doing some argument checks.

The first version doesn't use strict or my because they are introduced after the script was first shown. The second version does use them.

options1.pl

options2.pl

Sending an attached email

This script demonstrates how you could send a csv file via email as an attachment. It uses the Email::MIME::Creator and Email::Send modules.

email_csv.pl

Freehand Drawings

For each course, there is a subdirectory of this directory, named for the starting date of the course (yyyy-mm-dd format). This directory contains a zip file with the freehands and a directory containing all the files.

The most recent course (1st Feb 2008) is here.

To Nic's home page