Intermediate Topics in Perl
(Using and Building Modules)
Length: 2-3 days
Prerequisites: Students in this class should have had several months of experience
programming in Perl regularly.
Description
The class covers essential skills for developing software in industry,
particularly in group projects. We begin with a thorough examiation of
the use of references in Perl, and especially of their applications in
building complex data structures. The middle of the class introduces
modules, looks at the most useful of Perl's standard modules, and them
moves on to the nonstandard modules that are available on CPAN, the
comprehensive Perl archive network. (Most of these 'nonstandard'
modules have in fact become standard in the most recent version of
Perl.) The class then looks at how modules work and shows students how
to build their own modules, including a complete examination of Perl's
Exporter utility. Finally, the class ends with an examination of
Perl's facilities for automatic regression testing and an introduction
to the use of the Perl built-in debugger.
Outline
- Unit I: References and compound data structures
- 1: References and reference syntax
- Why references?
- Reference syntax: make rules 1 and 2; use rules 1 and 2
- Two-dimensional arrays
- Arrow rule
- City-country problem: output; input
- Hashes of arrays
- Printing out references
- Symbolic references; strict refs
- Finding the type of a reference
- Copying vs. aliasing
- Code references
- Passing two arrays to a function
- Schwartzian transform
- Lab 1
- 2: Typical Applications of References
- Multidimensional arrays
- Hashes as records
- Documentation
- Lab 2
- Unit II: Using Modules
- 3: Why Modules?
- Example module: Socket.pm
- Code sharing
- Encapsulation
- 4: Essential Standard Modules (3 day version only)
- Perl's standard library
- perlmodlib
- Getopt::Std and Getopt::Long
- File::Spec
- File::Find
- POSIX
- Text::ParseWords
- Time::Local
- DB_File; alternatives to DB_File; limitations of DBM
- Data::Dumper
- Lab 4
- 5: Introduction to CPAN
- What is CPAN?
- search.cpan.org
- Lab 5
- 6: Essential Nonstandard Modules (3 day version only)
- About perllocal
- Checking to see if a module is available
- Tie::File
- Text::CSV
- Text::Balanced
- Memoize
- MIME::Lite
- Digest::MD5; secure authentication with Digest::MD5
- Lab 6
- Unit III: Building Modules
- 7: Packages, Namespaces, and Modules
- Namespaces
- Extended package names
- Lexical variables
- Block scope
- package and my are unrelated
- Safety of lexical variables
- More my Declarations
- strict vars
- Summary of Scoping and Namespace Rules
- 8: The Exporter
- Importation and exportation
- Writing Modules
- Missing modules; missing functions
- The Exporter; exporting
- Unexported functions
- Why @EXPORT should be avoided; @EXPORT_OK
- Modules in the main file
- Several modules in the same file
- Carp
- Automatic interface checking
- "Did Not Return a True Value"
- Lab 8
- 9: Ins and Outs of use
- do
- What's in @INC? Ways to control @INC
- require; %INC
- use vs. require
- Compile-time effects; pitfalls of compile-time effects
- import
- Summary of use
- Lab 9
- Unit IV: Testing and Debugging
- 10: Unit Testing and the Test Harness (3 day version only)
- Why automatic testing?
- The test harness; Test::Harness
- Test file output
- Test outcomes
- Skipped tests
- Test
- Testing philosophy
- Other testing resources
- Lab 10
- 11: The Perl Debugger
- Starting the debugger
- Debugger display
- Debugger commands
- Debugger documentation
- Debugger integration with emacs
- Trivial debugger
- Lab 11
Return to:
Universe of Discourse main page |
Perl Paraphernalia |
Other Classes and Talks
mjd-perl-yak+@plover.com