Introduction to CGI Scripting with Perl

$800.00


  • Virtual Classroom

  • Onsite
Duration: 2 Days

Perl allows you to write powerful, flexible, platform-independent scripts that run on your server. Learn to harness Perl's potential for processing text, searching HTML pages and text files, and more.

What You Will Learn

 

  • Understand Perl commands and program structure
  • Use regular expressions
  • Build a searchable site index
  • Search a text file
  • Edit text dynamically

Audience

 

Students that want to develop complex, web-driven applications.

Prerequistes

 

Course Outline

 

1. Your Files for Class

  • What is a CGI script, and what is Perl?
  • What's special about a cgi-bin directory?

2. Perl Syntax

  • print statements
  • Identifying the Perl interpreter
  • The content-type header
  • Printing HTML content
  • Comments
  • Exercise 1: Building a Simple Web Page in Perl

3. Interpreting Variables

  • Scalar variables
  • Form variables
  • Exercise 2: Processing a Form

4. Working with Scalars

  • Scalars and arithmetic
  • Shortcut operation and sssignment
  • Autoincrement (++) and Autodecrement (--)

5. Conditionals

  • Testing existence of a variable
  • Comparing values
  • Combining multiple conditions
  • More than just if-else
  • Pessimistic tests with unless
  • Exercise 3: Testing Form Values with Conditionals

6. Pattern Matching

  • Case Sensitivity
  • Testing Environment for Regular Expressions
  • Some Common Patterns
  • Exercise 4: Validating Form Data

7. Pattern Substitution

  • Remembering text with Backreferences
  • Character translation
  • Exercise 5: Substitution and Backreferences

8. Array Variables

  • Creating an array
  • Individual array elements
  • Counting array elements
  • Reading one array into several scalars
  • Adding array elements with push
  • Removing an array element with shift
  • Exercise 6: Using Basic Arrays

9. More Array Functions

  • Reordering your array with sort and reverse
  • Search your array with grep
  • Change between array and scalar with join and split
  • Exercise 7: Practicing with Array Functions
  • A possible solution to Exercise 7

10. Loops

  • Looping with while and until
  • Looping with for
  • Looping with foreach
  • Exercise 8: Looping Through Your Array

11. Reading from and Writing to Files

  • A simple demonstration
  • What these scripts have in common
  • Adding text to a file
  • Reading lines from a file
  • Confirm that the file opened properly
  • Using split to parse tab-delimited text files
  • Exercise 9: Writing to a Text File
  • Exercise 10: Searching in a Text File

12. Listing Files in a Directory

  • Filtering file names with grep

13. Introducing Subroutines

  • How to write subroutines
  • Exercise 11: Building and Calling Subroutines

14. Making Your Subroutine More Reusable

  • Passing variables to a subroutine
  • Returning results from a subroutine
  • Variable scope with my and local
  • Exercise 12: Passing Variables to and from Subroutines

15. Hash Variables

  • Looping through a hash
  • Other hash manipulations
  • Environment variables: a ready-made hash
  • Another useful loop: all form variables
  • Exercise 13: Practicing with Hashes

16. Sending Email

  • The mail:mailer module
  • Exercise 14: Sending an Email Message

Course Labs