Course Outline
Perl is a mature, extremely flexible, general-purpose programming language, which is especially well-suited to textual manipulation. In addition to its brilliant built-in-facilities, there are vast freely-accessible libraries of Perl code to help build almost every conceivable application. And it’s available free-of-charge.
The capabilities of Perl have been applied by a wide range of professionals in both systems support and programming fields for various applications including manipulating text and data, database access, CGI programming, HTML generation, and parsing and generating XML files.
This five-day course provides a comprehensive examination of the major aspects of the Perl programming language and an overview of selected applications, with an emphasis on database and web server processing.
It covers basic through intermediate and advanced techniques and programming structures provided by Perl5. A number of mainly advanced topics are normally self-study, or as time allows.
This is a ‘hands-on’ course with many practical examples of everyday use of Perl, as well as some more substantial exercises.
Course Content
All exercises and examples are designed to achieve the maximum benefit for delegates. They aim to effectively demonstrate the concepts covered in the course and provide an opportunity to experiment with them; many of the exercises develop custom code which encapsulate complex functionality that can be used in numerous real world applications.
This course has been developed for real-world, commercial scenarios by our expert instructors. See below for detailed syllabus.
What you will learn
- Fundamental principals behind Perl.
- Data Types, Expressions, operators, and scalar data functions
- String processing & Manipulation
- Control Structures, Normal Arrays & Lists
- Functions and Subroutines
- Hashes (associative arrays)
- Handling Text Files
- Regular expressions
- Packages and modules
- Web Server Programming.
Perl with CGI Training Course Outline
Introduction
- Perl as a practical language
- Perl applications and capabilities
- Perl flavours, including Perl 6
- The CPAN
- Compiling and invoking Perl
Basics
- Program structure, including comments
- Standard input, output and error
- Input and output functions and constructs
Data types, expressions, operators
- Integers, floats, strings
- Scalars, variables, assignment and scope
- Creating expressions using operators
- Conversion functions
String processing and manipulation
- Unicode support
- Simple string functions
- More advanced string functions
- Regular expression basics
- Transliteration operator
Basic control structures
- Relational expressions
- Conditional processing: if , else, unless, elsif
- Logical operators
- Looping: while, until, for
- List constructor
- foreach with lists
- Simple subroutines
Other control structures
- The conditionasl operator
- Statement modifiers
- Using logical operators as control structures
- Labels and other loop constructs
Arrays and lists
- Defining normal (ordered) arrays
- Assigning and extracting values
- foreach with arrays
- Array dimensions
- Extending and reducing arrays
- Conversion functions: split, join
- List interpolation; slices
- Array functions: pop, shift, push, unshift, splice
- List functions: sort, reverse, map, grep
Functions and subroutines
- Creating your own functions and subroutines
- return value(s)
- Passing (and localising) arguments: the @_ array
- my, local, and state functions
- defined function
Hashes (associative arrays)
- Defining hashes
- Assigning and extracting hash elements
- keys function
- Hash element functions: exists, delete
- Accessing values: values, each
- Hashes in list/scalar context
- Hash dimensions; hash slices
Special variables
- Global special arrays
- Array and hash special variables
- Regular and per-filehandle special variables
Reading and writing text files
- Filehandles; open and close functions
- Opening files for input, output and appending
- Reading/writing individual/multiple lines
- die, warn, exit and the special variable $!
Format and the Write Function
- Declaring and defining formats
- Fieldline and fieldholder definition
- Invoking a format...the write function
- Changing the filehandle using select
- Top-of-page format
Introduction to references
- Creating references to anonymous data
- ‘Multidimensional’ arrays
- Reference types and ref function
- Referencing/dereferencing existing data
- Passing array and hash references to subroutines
- Hashes of arrays
- Arrays of hashes
- Sorting arrays of references
- Symbolic references
- Variables or blocks as variable names
More complex data structures
- Selecting the appropriate data structure
- Complex and nested data structures
- Data serialisation
- Data::Dumper
- Storable
Packages and module basics
- Package scope and symbol tables
- my, our, use vars;
- use and require keywords
- Module location: @INC and %INC; use lib
- Module invocation variations
- Standard library modules and examples
- Implementing simple modules
- Exporter standard module
Regular expressions
- Match and pattern-binding operators
- Metacharacters
- Alternation and grouping
- Character classes including special classes
- Anchors and word boundaries
- Quantifiers and greediness
- Capturing
- Backreferences
- Regular expression special variables
- qr operator and study function
- Use of modifiers
- Advanced and cloistered modifiers
- Substitution operator
- Global and Perl-expression substitution
- Extended regular expression sequences
Further file and storage features
- File tests, eg -e FILENAME
- Using @ARGV for multi-file processing
- In-place editing
- open modes
Emulating OS commands
- chmod, mkdir, rmdir, chdir functions
- link (Unix), unlink and rename functions
- stat and lstat functions, and module equivalents
- Cwd module
- system function
Directory contents
- glob function and alternatives
- Opening and closing directory handles
- Reading directory contents…readdir
- File::Find module
Time functions
- gmtime, localtime, time, times
- Time-related modules
Object-oriented programming
- Background to object-orientation
- Accessing object methods
- Class methods and attributes
- bless function
- The -> notation and variations
- Object-oriented wrappers for complex data
- Perl-style inheritance, @ISA special array
- Polymorphism
Ties and closures
- Introduction to the tie command
- Tied scalars, arrays and hashes
- Unix-like DBM databases and DBM hashes
- SDBM_File and similar modules
- Pseudo databases
- Tied handles
- Private data via closures
- Perl 5.10 state declaration
More on modules and packages
- Specialised import lists
- import function
- Multiple packages in a module
- Pragmas
- BEGIN, END and similar blocks
- eval blocks and eval function
- Default functions and methods
- AUTOLOAD functions
- UNIVERSAL package
Database processing
- RDBMS connectivity from Perl
- ‘Standard’ DBI/DBD approach
- ODBC and DBD::ODBC
- Other possibilities, eg Win32::ODBC
- Non-RDBMS data sources
Database interaction via DBI module
- Database modules: DBI and DBD::...
- Installing DBD modules
- Connecting to databases via DBI/DBD
- DBI->connect method; connection descriptors
- prepare and execute
- Fetching and retrieving data...fetchrow_array
- Other fetch..._... methods
- select... methods
- Standard error handling
- Updating data: INSERT, UPDATE, DELETE
Perl & web server programming
- The CGI specification
- Using Perl with a web server program
- Preparing a Perl program for web server use
- CGI.pm, related and alternative modules
- Unbundling data from the client
- Sending dynamic HTML documents
The CGI.pm module
- Function-oriented and object-oriented approaches
- The param function
- The header and start_html functions
- HTML output functions
- Handling forms
- Handling tables
- CGI with DBI (or Win32::ODBC)
- Alternatives, eg CGI::Lite
Other web server issues
- General Perl security issues
- Security issues in outline
- Redirection
- Serving exception and alternative output
- Maintaining state
- Persistent connections and scripts
Following are self-study or as time allows
- Miscellaneous functions
- srand, rand
- pack and unpack
- Other bitwise operators and functions
Typeglobs
- Typeglobs, local() and my()
- Applying typeglob aliasing
- Typeglobs and references
- Typeglobs and filehandles
The Standard Library
- Time modules
- Bechmark.pm
- Config.pm
The CPAN; example CPAN modules
- Installing CPAN modules
- Mime::Lite
- Net::SMTP
- HTML::Template
- GD
AUTOLOAD uses
- AUTOLOADing modules
- SelfLoader, AutoLoader and related modules
- The autouse pragma
Distributing modules
- h2xs utility
- The blib pragma
- Contributing to CPAN
Further DBI module features
- DBI metadata
- Transactions
- Customised error handling
CGI security in more detail
- General and specific security issues
- Security problem avoidance
- Denial of service attacks
- Restricting CGI permissions
Other applications
- XML parsing and processing
- Perl/TK introduction
- HTML parsing
- Perl and AJAX
Who Should Attend
Experienced developers who need a firm comprehensive foundation in the language and a succinct appreciation of the capabilities of Perl in selected application areas. Systems administrators, database administrators and testers; developers working with Perl applications of all types.