Perl Short Course: December 2011


dcw@doc.ic.ac.uk

This web page contains all the materials for my Perl Short Course, that I've just given this week (12th-16th December 2011) to Dept of Computing second year students.

Changes this year:

  • Lovely Ann Arbor colourful Latex Beamer format, wow! the Perl course enters the 21st century; only 11 years late:-)
  • 'my' variables from day one. (I also thought about using 'use strict' from day one: decided not to!)
  • used 'IO::File()' instead of 'open()'.
  • Creating modules part of lecture 6 replaced completely with new `maxfreq' example.

Here are the course materials, covering the lectures as I gave them:


First Session


Second Session


Third Session


Fourth Session


Fifth Session


Example CGI Scripts from the Fifth Session


Sixth Session

Please note that lecture 6 as printed did not contain maxfreq::forget() in eg1, immediately above the call to maxfreq::remember(); the notes below do!

Also, I realise there's an unanswered question in the slides - at the bottom of page 15/28, in the discussion of why printperson($person) isn't a method, it asks "how hard is converting a normal subroutine to a method?".

The answer is: incredibly easy in this case: printperson takes a person as it's first (only) argument. This is exactly like the object method calling convention, so it's very nearly a method already! Move printperson from eg1 to Person.pm and rename it print. Optionally rename it's $person argument as $self. Back in eg1, change all printperson($person) calls to $person->print.

In the examples tarball below, code after the above modifications will be found in the person-v2/ directory.


dcw@doc.ic.ac.uk
Updated: December 2011