Perl Programming and CGI Scripting
Price: Contact SST for pricing | Duration: 5 days
Prerequisites: Prior scripting experience or knowledge of fundamental programming concepts. For CGI programming, knowledge of HTML fundamentals and SQL is helpful but not required.
Description: This hands on Perl programming course provides a thorough introduction to the
Perl programming language, teaching attendees how to develop and maintain portable
scripts useful for system management, data manipulation, and Web CGI programming.
Emphasis is placed on built-in subroutines that can be used to help conveniently
build fast, portable and efficient scripts. Extensive hands on exercises provide
practice in report creation, pattern matching, string manipulation, file I/O,
command line processing, and debugging. Students are shown how to extend Perl's
basic functionality with packages and loadable modules. The final day encompasses
CGI scripting with Perl as well as database access using the DBI module. Attendees
are shown how to validate form data, how to perform robust database access, and
how to generate HTML output in order to create a dynamic web site. Attendees who
do not need or want in-depth coverage of CGI scripting and DBI should attend SST's
Perl Scripting
course instead.
Introduction to Perl
- Origin and Design Goals of Perl
- Overview of Perl Features
- Getting and Installing Perl
- Accessing Documentation via perldoc
- HTML-Format Reference Documentation
- Perl Strengths and Limitations
Using Variables
- Scalar Variables
- Introduction to Standard Data Types
- Retrieving Standard Input Using the Default Variable $_
- Assigning Strings and Numbers to Scalar Variables
- Declaring Constants for Persistent Values
- Using strict to Declare
Variables
Operators
- Introduction to Fundamental Operators
- Operator Precedence and Associativity
- Using the Ternary Operator ?: as a Shortcut for the if Statement
- Using <FILEHANDLE> and <> File I/O
Operators for Standard Input/Output
- Using the Shortcut Operators +=,
-=, *=, /=
Flow Control: Conditional
Statements and Looping
- Conditional Expressions and Logical Operators
- if/else/elsif and unless
- Constructing switch/case Equivalent Expressions
- while Loops and do Loops
- for and foreach Loops
- Labels
- Altering Program Flow with next,
last, and redo
- Trapping Errors with the eval Function
- Terminating a Script with exit
Arrays and Hashes
- Defining Numeric Index Arrays
- Defining Associative Arrays
- Sorting Arrays with the sort Function
- Adding and Deleting Items Using push,
pop, shift, and unshift
- Using slice, splice, and reverse
- Other Array Manipulation Techniques
- Looping through an Array
- Merging Arrays
- Introduction to Hashes
- Preallocating Memory to Optimize Hash Performance
File Manipulation
- Using open and close
- Difference Between print and write
- Reading and Writing Arrays
- Directory Manipulation Using opendir,
closedir, readdir, chdir, mkdir and rmdir
Implementing Command Line
Arguments
- Reading Command Line Arguments from @ARGV
- Manipulating Positional Parameters with push,
pop, shift
- Processing Command Line Options with getopt or getopts
- Analyzing Command Line Argument Values with the Getopt::Std and Getopt::Long Modules
- Reserved Variables
- Manipulating Identifiable Options Using GetOptions
Debugging In Perl
- Using the Built-in Perl Debugger
- Starting the Debugger
- Debugger Command Syntax
- Checking for Script Syntax Errors
- Solving Compile-Time Errors
- Single-Stepping through a Script
- Executing to Breakpoints
- Setting Global Watches
- Printing Values of Variables
- Listing All Variables Used in the Script
- Using strict Error
Checking
- Quitting the Debugger
CGI Scripting with Perl
- Perl's Role in Distributed Web Applications
- Using Environment Variables to Control CGI Scripts
- Communicating with the Web Server
- Perl CGI Script Instantiation and Invocation
- Generating Output for the Browser
- CGI Security Mechanisms
Fundamentals of CGI Scripting
with Perl
- Perl's Role in Distributed Web Applications
- Using Environment Variables to Control CGI Scripts
- Communicating with the Web Server
- Perl CGI Script Instantiation and Invocation
- Generating Output for the Browser
- CGI Security Mechanisms
- The Importance of the "Shebang" Line
- "Shebang" Line CGI Errors
- Debugging CGI Errors
- Linux vs. Windows File Format Errors
- Setting Linux File Protections
- Specifying the Page MIME Type
- Generating Standards-Compliant HTML
Dynamic Behavior Based on
Query Strings
- The Query String Part of a URL
- Parsing the Query String
- Using Query Strings to Maintain Session State
- User-Defined Modules and CGI
Development Cycle for HTML
Forms
- Dealing with Program Complexity
- Calendar and Time Functions
- Step 1 - Algorithm Development
- Step 2 - Algorithm Application
- Step 3 - Adding Form Elements
- Step 4 - Processing Form Elements
Form Processing with CGI.pm
- Classes of CGI.pm Methods
- Specifying Arguments for HTML Tags
- Differentiating Blank & Missing Parameters
- Using Passed Parameters as Numbers
Using Relational Databases
with Perl DBI: Basic RDB and SQL Concepts
- Multi-Tiered Architecture
- Database Servers and Connections
- Database Concepts and Terminology
- Database Table Components
- Categories of SQL Statements
- The SQL INSERT Statement
- The SQL SELECT Statement
- The SQL UPDATE and DELETE Statements
- Determining Whether MySQL Is Running
- Starting and Controlling MySQL
- Creating a MySQL Database
- Installing Perl DBD-mysql and DBI Modules
Performance Optimization
Using ModPerl
- Overview of Apache Web Server Functionality
- Comparing the Speed of CGI Scripting vs. ModPerl
- Configuring Apache with Perl and ModPerl
- Apache Strengths and Limitations
- Using the Apache::Registry Module
- Extending and Enhancing Apache Functionality