Perl Programming — a 4-day course
Synopsis
This course covers general Perl programming together with system and database interaction. This basic four-day course provides a grounding in using the Perl programming language as a successful Perl programmer and/or system administrator.
An expanded 5-day version of this course, Perl Programming with Web Development, is also available. The Perl Programming with Web Development course covers everything in this 4-day course, but additionally covers CGI and Perl for web development.
Suitable for
Delegates have usually encountered some Perl before, but may not always have found it easy to learn or use. The course is for developers who want to learn the Perl way of doing things. It emphasizes taking advantage of Perl's native productivity tools and techniques, rather than trying to ‘make do’ with other language's idioms.
The course covers the fundamentals of Perl from the beginning, as we have found that a good understanding of how and why Perl does things in particular ways helps everyone to learn more effectively; even those who have been programming in Perl for a couple of years.
If you are new to programming or web development and are contemplating the use of Perl we suggest that you read our notes on introductory courses first.
Prerequisites
- This Perl course assumes that delegates can already program in at least one programming language or scripting language, e.g., C, C++, Java, PHP, Visual Basic, Pascal, or COBOL.
Delivery
This is a hands-on practical workshop based around the coding of real-world solutions to real-world problems.
This Perl training course is available as an in-house Perl course for company groups. For in-house programmers the course can be extended with our full range of Perl modules, or the basic content can be taught over five days to enable more practical exercises and mentoring.
An expanded version of this course, Perl Programming with Web Development, is scheduled for public presentaion in London and Bradford.
Please contact us at training@gbdirect.co.uk to arrange delivery of any of our Perl courses for your company.
Publicly scheduled dates, locations, and prices
A schedule of dates for this subject is not currently available. Please call 0333 210 0140 or use our contact form to enquire about places and availability.
Contents
Preparing to Learn Perl
- About This Course
- What is Perl?
- Perl History
- Perl the Language
- Perl Programming Environment
- Running Perl Programs
- Running Perl Programs on Unix
- Running Perl Programs on Windows
- Very Basic Syntax
- Getting Perl to Help You
- A Sample Program
- Online Help
Perl: the Absolute Minimum
- Enough to Get Started
- The print Command
- Variables
- Scalars Numbers and Strings
- Literal Numbers
- User Defined Constants
- Literal Strings
- Interpolation into Strings
- Assignment
- Truth in Perl
- Comparison Operators
- Conditional Tests
- Comparing Values
- A Popular Coding Error
- Alternative Tests
- Multiple Tests
forLoopswhileLoopsuntilanduntil
Arrays and Hashes
- Arrays and Hashes
- Lists
- Writing Lists
- Arrays — for Storing Lists
- Using Lists and Arrays
- Iterating Over Lists
- Using
foreach - The
pushFunction - Indexing into Arrays
- Hashes
- Hash Syntax
- Accessing Elements of a Hash
- Hash Example
- Iterating Over Hashes
- Iterating Over Hashes Example
- Size of Arrays and Hashes
Perl: Input and Functions
- Simple Input
- Providing Standard Input
- Input Example
- Opening Files
- Reading and Writing Files
- Subroutines
- Subroutine Parameters
- Subroutine Parameters Other Ways
- Calling Subroutines
- Calling Subroutines Without Arguments
- Returning Values from Subroutines
- Function Miscellany
- Persistent Variables
Text Manipulation with Regular Expressions
- Regular Expressions
- Other Metacharacters
- Regular Expression Examples
- Alternation and Grouping
- Built-in Character Classes
- Built-in Character Class Examples
- Matching Strings
- Matching the Default Variable
- Case-Sensitivity and Matching
- Capturing
- Regular Expression Examples
- Substitution
- Global Substitutions
Perl: Operators and Loops
- Concatenating Strings
- Fancy Assignment
- Assignment Shortcuts
- Autoincrement and Autodecrement
- Complex Conditions
- Short-Circuit Operators
- The Conditional Operator (Ternary Operator)
- Bitwise Operators
- Operator Precedence and Associativity; Sequence Points
- Operator Precedence and Associativity
- Undefined Values
- Overview of Flow Control
- Statement Modifiers
- Flow Control with
or - Flow Control with
and - More Loops
- Loop Control
- Example of
nextandlastStatement
Perl: Beyond the Basics
- Quoting Mechanisms
- Disambiguating Interpolation
- Different Quote Symbols
q,qq,s///, andm//- Quoting Lists
- Quoting Really Big Strings
- Changing Between Case
- Splitting Strings into Lists
- Joining Elements of Lists
- Filtering Lists with
map - Combining
mapandjoin - Splitting, Mapping and Rejoining
- Using
mapto Initialise a Hash - The
sortFunction - Custom Sort Orders
grep- The Importance of Context
- Arrays in Different Contexts
- File Input in Different Contexts
- Functions in Different Contexts
- Providing the Right Context
- Context Pitfalls
- Boolean Context
voidContext- Special Variables
- Examples of Special Variables
- More Special Variables
- Input and Output Special Variables
- Scope
- Localizing Special Variables
- Using Command-Line Arguments
- Options Processing
Complex Data Structures & References
- Limits of Lists
- Nesting Arrays
- References in Arrays
- Dereferencing Array References
- Accessing a Particular Element of an Array Reference
- Arrays of Arrays
- The
Data::Dumper - Flexibility of Nesting Arrays
- Array References are Scalars
- Array Dereferencing Syntax
- Using the Arrow Operator
- Creating a Reference to a Named Array
- Passing Multiple Arrays to Functions
- Returning Multiple Arrays from Functions
- Hashes of Arrays
- Hash References
- Complex Data Structures
- Arrays of Hashes
- Hashes of Hashes
- Code References
- Invoking Code References
- Dispatch Tables
Finding Out More for Yourself
- So Far
- Perl is Big
- Look Things Up
- Main Perl Documentation
- Perl Doc Taxonomy
- Functions
- FAQs
- Reading the FAQs
- Searching FAQs
- The Perl Cookbook
- Other Perl Books
- Perl Websites
- Knowing What to Look for
Using Perl Modules from CPAN
- Perl Modules
- Using Modules
- Standard Modules
- CPAN Modules
- Why Effective Perl Programmers are Efficient CPAN Users
- Finding Modules on CPAN
- Installing Modules
- The
cpanCommand - Finding Installed Modules
- Writing Perl Modules
- Perl Module Boilerplate
- Perl Module Boilerplate Explained
- Defining Functions in Modules
- Exporting Functions
- Exporting Functions - II
- Module Variables
- The Exporter
- Module Initialization
- Versions
PODPlain Old DocumentationFile::CopyFile::FindText::Wrap
Debugging Perl
- Bugs
- Avoiding Bugs
- Perl's Built-in Debugger
- Debugger Documentation
- Using the Debugger
- Debugger Commands
- Advanced Debugger Commands
- Other Debugger Functionality
- Graphical Debugging
ptkdbDDD- Komodo
- Shunning the Debugger
- Using
warnfor Debugging CarpModule- Printing Nested Data Structures
- Using the Debugger as a Perl Shell
- Unix and Linux Specific Tools
Command-Line Perl
- General Principles
- Quoting Command-Line Perl Programs
- Command-Line Perl
- Command-Line Perl Syntax
- Using Modules
- Using Perl as a Filter
- Looping Through Input with
-n - Transforming Input with
-p - Editing Files In-Place with
-i - Backing Up In-Place Edits
- Other Command-Line Flags
- Autosplit Mode
- Example: Locale-Aware Downcasing
- Example:
grepin Perl - Example: Unix-Epoch Times
- Example: Summing Input Lines
- Example: Selecting a Range of Lines
- Example: Find Emphasised HTML Words
- Example: Printing Unique Input Words
A Whistle-Stop Tour of the World of Perl
- Built-in Functions
- General String Manipulation
- Extracting Bits of Strings
- Changing the Case of Letters
- Converting Between Strings and Numbers
- Mathematical Operations
- Formatted Strings
- Handling Binary Data
- General List Manipulation
- Adding and Removing from Arrays
- File-System Functions
- Idiomatic Perl Programming
- Handy Tricks with Variables
- Removing Duplicates
- Formatting Text
- Sending Email
- Sending Email — Unix-Specific
Perl Style
- Style Issues
- Indentation
- Identifier Naming
- Naming Variables
- Naming Functions
- Global Variables
- Using
$_for Readability - High-Level Comments
- Low-Level Comments
- Parentheses
- Quoting
- Program Logic
- Structuring Data
- Modelling the World
- Object Orientation
- Style Resources
Handling Databases with Perl
- Interacting with SQL Databases Using Perl
- Using
DBI - Opening a Connection with
DBI - Example Query
- Running a Query
- Retrieving Records from
SELECT - Retrieving a Single Record
- Retrieving All the Records at Once
- Queries Which Don't Return Records
- SQL Injection Attacks
- Placeholders and Bind Values
- Two Last Notes
- Using ODBC
- Opening a Connection
- Executing Queries
- Fetching Records
- Reading Values from Records
- Other ODBC Methods
- Database Related Modules
- Tieing Hashes to Files
- Sample Database
Advanced File Processing
- Opening Files
- Appending to Files
- Alternative File-Opening Syntaxes
- Predefined File Handles
- Redirection-Style File Opening
- Input and Output
- Controlling Output Formatting
- Controlling Input Formatting
- Reading Paragraphs
- Reading a Whole File
- Reading Fixed-Sized Blocks
- The Flip-Flop Operator
- Handling Binary Files
- Output from Multiple Processes
- Examining Directories
- Examining File Metadata
- File Test Operators
- Symbolic Links
- File Locks
- Locking Files with
flock
System Interaction
- Connecting to Other Programs
- Unsafe Pipes
- Using
IO::Pipe - Grabbing a Programs Output
- Other Ways to Run Programs
Perl Security Issues
- Writing Secure Perl
- Taint Checking
- Using Taint Checking
- Dangerous Environment Variables
- Input from Files
- Set-User-ID Perl Programs
- Permissions and Users
References
- Interesting Web Links
