Advanced Perl (3 days)

Synopsis This in-depth course teaches students many advanced features of Perl, using a single progressive project as the focus.
Target audience This course is appropriate for application developers, DBAs, advanced users, system administrators and Web site administrators, and anyone else who wants to automate or simplify common tasks.
Prerequisites In addition to a user-level knowledge of an operating system such as UNIX or Windows 95, students should have a solid grasp of basic Perl programming. Of course, a good prerequisite is our Programming Perl class.
Lab exercises After the first two chapters, which review basic Perl material and introduce some advanced techniques, all remaining labs are focused on creating a progressive real-life project: building a database of workstation information. Each chapter's lab will contribute to the overall goal. For instance, in chapter 5, students will make a library module to build and query the database; in chapter 6 they will create a Host object; in chapter 9 they will create a graphical front-end for the database.

Course Outline

1. Using Shortcuts

  • The ubiquitous $_
  • How to use <>
  • Pattern matching in brief
  • File tests on _
  • Command-line shortcuts

2. Data Wrangling

  • Reading text files
  • Creative use of <> and $/
  • Matching and substituting
  • RE review
  • Using backreferences
  • Parsing lines
  • Using here documents and __END__
  • Converting data with pack/unpack

3. Reference Refresher

  • Creating references
  • Dereferencing
  • References and subroutines
  • References and arrays
  • Complex data structures

4. The Perl Library

  • quick tour
  • use vs. require
  • Library files
  • Perl modules
  • Bundled libraries and modules
  • case study: Using Getopt::Long

5.Creating Modules

  • Review of subroutines
  • Understanding my() and local()
  • Packages and the symbol table
  • Mechanics of module creation
  • Exporting subroutines and data
  • Using BEGIN and END
  • Good module design

6. Object-oriented Modules

  • What's OOP and why?
  • Perl's approach to OOP
  • Indirect subroutine call syntax
  • OOP Terminology and Perl
  • Understanding bless
  • Constructors
  • Data structures
  • Object methods
  • Using objects

7.Databases

  • Creating and using DBM files
  • Saving complex data structures with freeze/thaw
  • Understanding DBI/DBD
  • Connecting to a database
  • Creating and executing an SQL statement
  • Fetching results
  • Using ODBC

8. Network Programming

  • About clients and servers
  • Ports and IP addresses
  • Sockets and the Socket module
  • The IO::Socket module
  • A simple client
  • Accessing standard services
  • A simple server
  • A more interesting C/S application

9.Graphics Programming with Tk

  • Tk overview
  • Widget tour
  • Geometry management
  • Event handling
  • Understanding callbacks
  • Binding keystrokes to subroutines