|
3 days
50% Lecture/50% Lab
Basic Level
The Practical Extraction Report Language (Perl) is a popular and portable scripting language used by anyone who needs to extract and manipulate data coming from text files, log files, databases, pipes etc. Perl is extremely powerful and fast, but easier to learn than languages like C and Java. The student will be able to produce working and meaningful Perl programs upon completion of this course.
Upon completion of this course, students will be able to:
- read, write and customize Perl scripts
- use Perl data types: scalars, arrays, and hashes
- use Perl operators to test and manipulate strings and numbers
- use programming constructs such as loops and decision making constructs
- use the power of regular expressions for extracting selected patterns in text
- open, close and test files and pipes
- modularize programs with subroutines
- debug Perl scripts
This course is recommended for people with a basic programming background who need to gain a working understanding of Perl for extracting and manipulating data.
Students need to be familiar with the basics of programming and the use of a text editor. Although Perl can run on a number of operating systems, the course is normally taught in a UNIX/Linux or Windows environment.
Advanced Perl
This is an intensive, interactive course, which is approximately 50% lecture and 50% lab. Questions are highly encouraged. On the final day, students are given access to a zipped file containing all of the solutions to the labs and the examples used throughout the notebook.
Day One
Module 1-- Perl Syntax
- What is Perl?
- Perl at the command line
- Versions of Perl
- Where to find Perl
- What is CPAN?
- Perl Documentation
- Basic structure of a Perl script
- Printing functions
- Literals -- Numbers and Strings
- Quoting rules
- Here Documents
Lab Exercise 1
Module 2 -- Data Types
- What are Perl variables? (Types, Naming conventions, and Scope)
- Scalars (Assignment, $_scalar)
- Arrays (Simple lists, multidimensional lists, assignment)
- Some Array Functions (pop, push, shift, unshift, split, join, reverse)
- Associative Arrays/Hashes (Assignment, extracting keys and values)
- Some Hash Functions (keys, values, each)
- Reading from STDIN
Lab Exercise 2
Day Two
Module 3 -- Operators
- What are operators?
- Precedence and associativity
- String and arithmetic operators
- Assignment operators
- Relational, equality and logical operators
- Autoincrement and autodecrement operators
- Bitwise operators
- Conditional operator
- Range operator
- Random Numbers
Lab Exercise 3
Module 4 -- Conditions and Loops
- Conditional Statements
- Loops
- Looping Constructs
- Loop Control
- labels
- redo, next and last
Lab Exercise 4
Module 5 -- Regular Expressions
- What is a Regular Expression?
- Simple Statements and Modifiers
- Pattern Matching
- The match operator
- The substitution operator
- Regular Expression
- Metacharacters
- Anchors
- The Dot
- Character Sets
- Metasymbols
- Greedy Quantifiers
- Alternation
- Grouping
- Capturing
- Repeating
Day Three
Module 5 -- (continued)
Lab Exercise 5a
- Translation -- the tr function
- Pattern Matching Operators
Lab Exercise 5b
Module 6 -- User-defined Filehandles
- What is a Filehandle?
- The die function and STDERR
- Opening files for reading
- Closing files
- Closing files for writing
- Opening files for appending
Lab Exercise 6a
- Pipes
- Output filters
- Input filters
- File Positions
- The eof function
- The seek function
- The tell function
- Open for reading and writing
- File Testing
Lab Exercise 6b
Module 7 -- Subroutines
- What are Subroutines
- Defining and Calling subroutines
- Forward Reference
- Passing by Reference
- Local variables and the my functions
- Passing by Value
- The return statement
Lab Exercise 7
|