United States flagCanada flag1 877 849 1850 International flag +1 678 648 311
Please contact us
for GSA pricing.
Contract #

Perl Training: CGI Programming with Perl

Course Number: PRL-130
Duration: 5 days
view course outline

Perl Training Overview

Perl is a powerful scripting language that has been popular for more than a decade. In this engaging, hands-on class, attendees learn how to use Perl CGI (Common Gateway Interface) scripts to develop database-driven Web applications.

Location and Pricing

Most Accelebrate courses are delivered as private, customized, on-site training at our clients' locations worldwide for groups of 3 or more attendees and are custom tailored to their specific needs. Please visit our client list to see organizations for whom we have delivered private in-house training. These courses can also be delivered as live, private online classes for groups that are geographically dispersed or wish to save on the instructor's or students' travel expenses. To receive a customized proposal and price quote for private training at your site or online, please contact us.

In addition, some courses are available as live, online classes for individuals. See a schedule of online courses.

Perl Training Prerequisites

Prior knowledge of HTML, as taught in Mastering XHTML and CSS, is required. This course can be adapted to any level of programming experience, from first-time to veteran programmers.

Hands-on/Lecture Ratio

This Perl training class is 70% hands-on, 30% lecture, with the longest lecture segments lasting for 10 minutes. Students "learn by doing," with immediate opportunities to apply the material they learn to real-world problems.

Perl Training Materials

All Database-Driven CGI Programming with Perl training students receive a copy of Peachpit Press's Perl and CGI for the World Wide Web and related course material.

Software Needed on Each Student PC

  • Windows, MacOS, or Unix operating system
  • The latest version of Perl installed
  • A text editor for editing the Perl scripts (please contact us to discuss the best editor for your environment)
  • A web server with Perl installed (such as Apache httpd with Perl and mod_perl, or Microsoft IIS with ActivePerl)
  • CGI.pm and DBI.pm
  • A database of the customer's choice (MySQL recommended; almost all major databases can be accommodated)
  • The appropriate DBD (DBI database driver) for the database

Perl Training Objectives

  • To learn the fundamentals of the Perl programming language and how it can be used to write Web-based applications
  • To master the use of the CGI.pm module, which greatly streamlines development of Perl CGI scripts
  • To discover how to use of the DBI.pm module and related DBD (driver) files with Perl to build database-driven applications

Perl Training Outline

  • Introduction
  • Introducing Perl and CGI
    • Origins of the language
    • The difference between Perl and CGI
    • The relationship between Perl and HTML
    • Understanding the Web browser-Web server relationship
    • Installing and configuring Perl for your environment
      • Will be customized to Windows, MacOS X, Linux, Solaris, or another operating system based on the attendees' server platform
    • Extending Perl's functionality with modules
    • The roles of CGI.pm and DBI.pm
  • Perl building blocks
    • Perl data
    • Operations and functions
    • Quotation marks
    • Quoting without quotes
    • Statements, blocks, and scope
    • Declaring private variables
    • The "shebang" line
    • Creating a Perl CGI script
    • Creating output for a browser
    • Documenting your script
    • Checking the script's syntax
  • Getting data from visitors (can be accelerated or skipped if attendees are fluently familiar with HTML forms)
    • Labeling incoming data
    • Creating a form
    • Creating:
      • Text boxes
      • Password fields
      • Text areas
      • Radio buttons
      • Check boxes
      • Select lists and menus
      • Submit and reset buttons
      • Image buttons
    • Specifying the action of the form
    • Understanding form methods: GET vs. POST
    • How your script processes data from a form
    • How your script processes data passed via a hyperlink
  • Environment variables
    • Your visitor's browser and platform
    • Viewing available environment variables
    • Storing data from environment variables
  • Getting data into the script
    • Getting single-value form data
    • Getting multiple-value form data
    • Getting the names of all form elements
    • Retrieving values from each of these elements
  • Simple operations with scalar variables
    • What is a scalar variable?
    • Assigning a value to a scalar
    • Multiplying, dividing, adding, subtracting
    • Using more than one operators
    • Raising a number to an exponential power
    • Using mathematical functions
    • Concatenating (joining) strings
    • Repeating a string
    • Operating and assigning in one step
    • Incrementing or decrementing a variable
  • Conditionals and loops
    • Comparing numbers
    • Comparing strings
    • Evaluating conditions without comparisons
    • Testing two or more comparisons at a time
    • Creating a basic conditional statement
    • Adding options for false conditions
    • Adding multiple, independent conditions
    • Using unless
    • Loop structures:
      • while and until
      • for
      • foreach
    • Using break to exit a loop
    • Using continue to start the next iteration of a loop
  • Working with arrays
    • Assigning a list to an array variable
    • Referring to a particular item in an array
    • Referring to multiple items from an array
    • Using shift(), unshift(), push(), pop(), and splice() to add, remove, or replace items in an array
    • Using sort() and reverse() to change the order of an array
    • Using length() to determine how many elements are in the array
  • Subroutines
    • Why create subroutines?
    • Using a simple subroutine
    • Creating and calling subroutines
    • Processing values passed to a subroutine
    • Returning a value from a subroutine
    • Storing subroutines in a separate file
    • Loading subroutines from a separate file
  • Working with hashes
    • Why use hashes?
    • Assigning a list to a hash
    • Getting a value using a key
    • Adding or replacing a key-value pair
    • Getting several values using keys
    • Getting all of a hash's keys
    • Getting all of a hash's values
    • Getting each key and value in a hash
    • Getting pairs in a specified order
    • Removing key-value pairs
  • Analyzing data and validating form submissions
    • Why analyze data?
    • In-depth primer on regular expressions, which enable simple or complex patterns to be detected within text strings
    • Finding something
    • Finding and replacing
    • Seeing and using what was found
    • Splitting a value into pieces
    • Constructing search patterns
    • Matching a single character
    • Matching a string of characters
    • Matching a character from a group
    • Matching a character that's not in the group
    • Using class shorthands
    • Advanced regular expression techniques
    • Form validation
      • Client-side, server-side, or both?
      • Defining validation rules and analyzing submitted data
      • Returning messages back to the user about whether their form submission is valid or invalid
  • Remembering what visitors tell you
    • Overview of strategies for maintaining user information and application state
    • Using hidden fields to store and pass data
    • Using cookies to store and pass data
      • Setting a cookie
      • Restricting a cookie by domain and/or path
      • Setting the expiration of a cookie
      • Requiring the presence of a secure connection
      • Retrieving and working with cookie values
      • What to do when a user's browser refuses to accept a cookie
  • Formatting output
    • Formatting output with Perl
    • Creating a format pattern for integers
    • Creating a format pattern for non-integers
    • Creating a pattern for strings
    • Changing case
    • Changing characters
    • Finding the length of a string
    • Extracting one string from another
    • Cleaning up the end of a string
  • Formatting output with HTML
    • Overview of CGI.pm's capabilities for automatically-generating HTML
    • Generating the HTTP header
    • Using start_html() to generate the document head
    • Concluding the page with end_html()
    • Dynamically generating text and tables of text
    • Dynamically generating hyperlinks and images
    • Dynamically generating forms
    • Styling output with CSS
  • Introduction to CGI/Perl security
    • Reading the security FAQs
    • The problem with visitor input
    • Protecting calls to the system
    • Limiting access to files
    • Using CGI.pm to limit incoming data
    • Keeping information to yourself
    • Avoiding tainted data
    • Cleaning and using outside data
  • Files and directories
    • Opening a file
    • Verifying file and directory operations
    • Writing to an external file
    • Getting exclusive access to a file
    • Reading data from an external file
    • Closing a file
    • Renaming or removing a file
    • Checking a file's status
    • Opening, reading from, and closing directories
    • Changing the working directory
    • Creating a directory
    • Changing permissions from within a script
    • Removing a directory
  • Generating email messages from your scripts
    • Routing data from Perl to mail, sendmail, or another application or module that will mail it
    • Important security considerations
    • Adding file attachments
  • Processing file uploads
    • Why upload files via HTML forms?
    • Setting the enctype and method of the form to facilitate uploads
    • Defining one or more file fields in the form
    • Controlling where the uploaded file is saved
    • Preventing common security issues that can arise when saving uploaded files
  • Database connectivity: introducing the DBI module
    • Origins of DBI, the database interface module
    • DBI architecture
    • Overview of available DBDs (database drivers)
    • Setting up and configuring DBI and DBDs
  • Selecting records from the database via ad hoc queries
    • Building a SQL SELECT statement
    • Sending the SQL statement to the database for execution
    • Displaying a single value returned from the database
    • Displaying multiple rows of data returned from the database
    • Handling errors that can occur when interacting with the database
  • Inserting, updating, and deleting records
    • Building SQL INSERT, UPDATE, and DELETE statements
    • Building Web-based interfaces for inserting, updating, and deleting database records
    • Validating user input
    • Prompting the user for confirmation
    • Grouping related operations together as transactions so that they either all succeed or all fail
  • Invoking stored procedures
    • Why use stored procedures instead of ad hoc SQL queries?
    • Defining stored procedures
    • Invoking stored procedures
    • Passing input parameters to stored procedures
    • Retrieving output parameters from stored procedures
    • Handling in/out parameters
  • Finding, downloading, and installing additional Perl modules from CPAN (the Comprehensive Perl Archive Network)
  • Conclusion