Beginning Perl
Private Training
Perl is a simple, yet powerful, scripting language that can be very useful for automating repetitive tasks, processing text and acting as a glue between other programs. This 3-day class introduces Perl to both new programmers and experienced ones who want to learn a new language. It provides a host of real-world applications for today’s environments so readers can get started immediately.
Audience
Programmers and/or system administrators.
Course Length
3 Days
Prerequisites
Programming experience in a structured language, such as C, C++, Java, or COBOL, is recommended.
Objectives
Describe the fundamental data types for Perl
Create and access arrays
Program with branching and looping constructs
Create and access hashes
Input from the keyboard and output from the screen
Utilize regular expressions with Perl
Create and use functions
Detailed Outline
- Introduction – Meet Perl
- Origin of Perl
- Perl Versions
- Invoking Perl
- Perl Documentation
- Perl Resources
- Scalar Variables
- Numeric Literals
- Manipulating Numbers
- String Literals
- Manipulating Strings
- Single vs. Double Quotes
- Scalars Variables
- Undefined Variables
- Auto increment and decrement
- Reading data from the user
- Chomp & Chop
- Curly Braces
- Additional Resources
- Array Variables
- Referencing Array Elements
- Adding & Removing Elements
- The Splice Function
- Using for Loops
- The Reverse Statement
- The Sort Operator
- The qw & qq statements
- Arrays used in scalar context
- Additional Resources
- Associate Array Variables
- Crating Associate Arrays
- The Values Statement
- Reverse searching an associative array
- exists vs. defined
- Special Variables
- The Environment Variables
- The Argument Variable
- Additional Resources
- Flow Control
- Blocks
- The if Statement
- The unless Statement
- The switch Statement
- The given Statement
- The while Statement
- The until Statement
- The do Statement
- Loop Control: last
- Loop Control: next
- Additional Resources
- Conditional Expressions
- Numeric Comparison
- String Comparison
- Pattern Matching
- Using the Outcome of a Statement
- File Test Conditions
- Complex Conditional Expressions
- Understand and/or versus &&/||
- Using Parentheses
- Short Circuiting
- Additional Resources
- Basic Input and Output
- Reading Input
- while & until Loops
- Record Separator Variable
- The Diamond Operator
- The Default Variable
- Using Parentheses
- Advanced Input and Output
- Filehandles
- The die and warn Statements
- Opening and Reading from Files
- Opening and Writing to Files
- Reading a Block of a Filehandle
- Reading a Single Character
- Piping in Perl
- The format Statement
- Here Documents
- Additional Resource
- Pattern Matching
- Pattern Matching vs. Wildcards
- Matching, Substituting and Translation
- Modifiers
- Regular Expressions: Metacharacters
- Regular Expressions: Classes
- Regular Expressions: Backreferencing
- Perl Utilities
- split
- join
- substr
- index
- rindex
- grep
- srand & rand
- sleep
- Additional Resources
- Filesystem & Process Control
- Controlling the Filesystem within Perl
- Working with Directories
- Working with Files
- Back-Quoting
- The System Statement
- Additional Resources
- Functions
- Creating Functions
- Invoking Functions
- Returning Values from Functions
- Passing Parameters
- Scope of Variables
- local() vs. my()
- Additional Resources
- Using Modules
- What are Modules?
- Loading Modules with use
- Other Functions of use
- Additional Resources
- Debugging Perl
- The –w Switch
- The Perl Debugger
- Debugger Commands
- Additional Resources