Perl Intermediate


Description Perhaps one of the most important features of Perl is its vast library of prewritten modules. Taking advantage of this library requires understanding and skill with the Perl language.

Building on the fundamentals of our Introduction to Perl training, this intermediate Perl training course will extend your ability to write useful scripts and show you how to install and use Perl modules. You will also learn of potential pitfalls of using modules and how to avoid them.

Intro to Perl or equivalent previous experience: must be able to write basic Perl scripts

Command-line Options & the Perl Debugger
Using the Perl interpreter effectively means having a solid understanding of command-line options, called switches, which change the way Perl normally operates when you run it. Here, you will learn to set switches to:

  • Set command-line switches to control the Perl interpreter
  • Run a line of Perl code without having to create a program to test it
  • Invoke the Perl debugger using the debugger switch
  • Step through your program's execution one line at a time

Working with Arrays in Perl
Working with lists is a critical programming activity, and Perl uses both arrays and 'hashes,' known as associative arrays, to store a list of values. In this portion of our Perl training, you will learn to create arrays and hashes, work with them, and retrieve values based on either their name or position. You will know how to:

  • Create a list of values and store them in an array
  • Insert items from an array and remove them
  • Scan through a list and retrieve a specific item
  • Use special arrays that are built into Perl
  • Work with associative arrays, or hashes

Subroutines & Include Files
Subroutines are the building blocks of Perl, and using them will allow you to organize code that performs a specific task in one place. Our instructor walks you through the ins and outs of subroutines, and shows how you can include them from other files. When you have completed this section, you will know how to:

  • Create a subroutine in your program
  • Pass values to a subroutine to operate on a specific problem
  • Place subroutines in a separate file and include using a require() function

File Input & Output in Perl
One of the benefits of using Perl is its powerful file I/O features, which allow you to quickly and easily read text from a file and change its contents. Our instructor presents a real-world example, showing how you can open a phone book, retrieve contact information, and modify that phone book. After your training in Perl's file input and output features, you will be able to:

  • Open any text file and read its contents
  • Use arrays to store individual lines of text from a file
  • Append any amount of text to existing text files
  • Overwrite text files with new information

Scoping, Namespaces, & Modules
With the thousands of Perl modules available, you will want to include modules from others as well as create your own. One pitfall, however, is that your code can unintentionally affect these so-called 'black boxes.' If you don't define a scope for your variables you run the risk of overwriting important information between your variables and the modules' variables. Our instructor introduces you to lexical scoping and describes the three scoping operators that will insulate your code. You will also learn how to use namespaces to protect code in modules. Completing this critical session of our intermediate Perl training will enable you to:

  • Create and use your own modules
  • Define a scope to isolate variables in your subroutines
  • Use scoping operators to apply to either local or global variables
  • Apply namespaces to distinguish common names in different modules

Perl Modules
With the thousands of Perl modules available on the Comprehensive Perl Archive Network (CPAN), you will want to begin exploring this vast library of useful modules. In this session you will examine several well-known modules, including popular ones such as LWP::Simple, Mail::Sendmail, and CGI. When you have finished this training you will know how to:

  • Work safely with modules created by others
  • Call subroutines in other modules
  • Decipher the notation in Perl modules
  • Send email from your application
  • Connect to a web site and programmatically retrieve its HTML into a Perl variable