1. At least 1 year production experience with another programming language
2. Basic knowledge of Linux (using a graphical user interface such as Gnome or MATE, starting programs
such as a browser, locating programs in a menu)
3. Some ability to use command line in Linux or Windows cmd (navigating through the file system, executing
programs from the terminal and stopping them, starting or stopping services)
4. Can use ssh/putty and understand the basics of networking (IP addresses, DNS, HTTP)
5. Understand the basics of HTML (tags, understand the basics of CSS)
6. Understand the basics of relational databases (tables, columns)
The Comprehensive Perl Programming course will provide an introduction to the Perl
programming language aimed at trainees which are familiar with another programming
language. The trainees will start with the basic syntax and will end by being able to write code
independently and accomplish non-trivial tasks, and will be able to read and have a hope to
understand legacy code written in Perl.
The trainees will
* will understand and be able to use effectively the core syntax (types, conditionals, loops, datas tructures,
subroutines, regular expressions, modules and Object Oriented Programming) and write non-trivial code
* will be able to create their own libraries and distributions
* will be made aware of most used code distributions, both modern (Test::More, DBI, Text::CSV, LWP, Plack,
Data::Dumper) and legacy (CGI)
* will understand the difference between procedural programming, OOP and functional programming as
applied to Perl
* will know where to find further sources of code and information (books, inline documentation, user groups,
CPAN)
* will be made aware of advanced options available when writing Perl:
- one liners
- the basics of using a debugger (the equivalent of gdb in C++ for example) and what other alternatives to
using a debugger there are available
- benchmarking and profiling Perl code
Course outline
For each day there will be a main goal and stretch goals. Depending on how smooth things go
while accomplishing the main goal the stretch goals might or might not be attempted.
The content presented during each day after the first will revise the information introduced in the
day before and expand on it, so perfect attendance is strongly recommended.
The course will take place in chunks of 50 minutes followed by a 10 minutes break.
Day 1
The first day will be dedicated to the Perl syntax and to small exercises. The trainees will be
provided at the start of the day with a PDF file containing the code exercises and a summary of
the information to be taught. When explaining the concepts might be compared with similar
concepts from Java/C# or C/C++.
* Short overview of the Perl programming language, including history, evolution and versions, common use
cases, creating and executing a Perl script in a Linux terminal, where to find documentation online and how to
read documentation for builtin functions using the Linux terminal, BASH concepts that the trainees might miss
(max 1h)
* Basic syntax (4h, relying heavily on previous programming knowledge)
- variables and data types, including explanation of what sigils are and are not
- most used builtin functions
- subroutines and functions (and what is the difference)
- passing arguments to subroutines by value or by reference
- options for returning data from a subroutine (return or via a reference sent in arguments)
- context (list and scalar)
- references to variables and subroutines
- blocks and scope and variable lifespan (my, local, our)
- loops and conditional expressions
- operators and what does Perl do different
- code libraries: main scope, packages, modules, module distributions
- modules: loading modules and variable and subroutine visibility across packages
- modules: module inheritance (use base, use parent, calling subroutines in modules and how it works with
module inheritance)
- modules (Object Oriented Programming): the bless function, Perl not having a default constructor name
and using factory methods as constructors, calling methods
* Advanced syntax (2h)
- STDOUT, STDERR
- reading from and writing to files
- passing arguments in the command line to a Perl script
- sorting (numeric, alphanumeric)
- subroutine references
- deep data structures using references
- map and grep
- function signatures and when to use them
- using BASH commands from withing a Perl script
* Questions and revision (1h)
Stretch goals:
* practicing with basic scripts to explore the file system
* basic introduction to symbol table manipulation
Day 2
The second day will be dedicated doing small tasks at the discretion of the trainer which will
exercise the knowledge about syntax. All tasks will be practical and the trainees will be required
to work independently on them
* install a CPAN module using the command line using cpanm
* create a module distribution using Module::Starter, installing it and using code inside it for the following tasks
* automated/unit testing will be introduced using Test::More, and tests will be added to the module distribution
the trainees will create
* listing files inside a folder and finding files by name
* reading from a text file and writing to another text file (open/close)
* filtering the contents of a text file
Stretch goals:
* write a basic reimplementation the grep command, including making use of modules written by the trainees
or installed from CPAN. The reimplemented grep will receive as arguments a folder and a string and will read
recursively the contents of that folder and attempt to find files containing that string
* introduce Getopt::Long and add command line options to the reimplementation of grep
* reading from a binary file and writing to anothe binary file (read)
Day 3
The third day will be dedicated to a single larger task which will exercise the knowledge about
syntax and will use larger CPAN modules. The trainees will be provided with a CSV file and
working cooperatively will read it, parse it using Text::CSV, and insert the data into a MySQL
database using DBI.
Stretch goals:
* The trainees will be introduced to the perl debugger (perl -d) and basic usage in the command line (starting,
running, stepping, breakpoints, inspecting data). The trainees will also be introduced to Data::Dumper and
how to inspect data in a running script without using a debugger.
* basic benchmarking using the CPAN moduel Benchmark
* DBIx::Class will be briefly introduced as representative for the state of ORMs in Perl
Day 4
The last day will be dedicated to writing a basic web application using CGI on Apache2. The
history and meaning of CGI will be presented. To save time Apache virtual host configurations
will be provided and the basics of apache configurations will be explained in short. The GGI
application will display and update the data written to the database during the previous day.
Plack and Starman will be introduced as alternatives to CGI. Options for running plack
applications under Apache2 will be presented.
The trainees will be introduced to what options there are in Perl for benchmarking and profiling
(Benchmark and Devel::NYTProf).
Stretch goals:
* the CGI code written previously will be updated to run on Plack and Starman. The HTML code needed will
be provided by the trainer in order to save time.
* the trainees will attempt to improve the efficiency of code they wrote previously and check their progress
using Devel::NYTProf profiler.