Introduction
The tutorial presented on the following pages is a revised version of a tutorial I presented twice at a previous job. We held class one hour a week during lunch hour over a 14-week period. The students, who were all scientists, were asked to complete the the weekly homework assignments, and later in the course the students applied their new skills to projects related to their work.
I am still working on the revision, so some of the lessons are incomplete.
Outline
- Lesson 1
- Lesson 2
- Lesson 3
- Lesson 4
- Lesson 5
-
Lesson 6
-
Numbers
- Designating numbers
-
Math operators
-
Adding with the
+operator -
Subtracting with the
-operator -
Multiplying with the
*operator -
Dividing with the
/operator -
Finding the remainder with the
%(modulo) operator -
Calculating a power with the
**(exponentiation) operator -
Combining math operators with the
=(assignment) operator - Incrementing and decrementing numbers
-
Adding with the
- Math functions
- Strings
- Printing formatted numbers and strings
- Homework assignment
-
Numbers
-
Lesson 7
-
Lists and arrays
- Lists
- Assigning lists to scalar variables
- Array variables
-
Using
scalar()to find the number of elements in an array - Using individual elements of an array
- Using more than one element from an array
- Initializing individual elements of an array
- Adding elements to or removing elements from the ends of an array
-
Sorting lists and arrays using
sort() -
Looping using
foreach -
The pragma
use warnings;revisited - A summary example script
- Homework assignment
-
Lists and arrays
- Lesson 8
- Lesson 9
- Lesson 10
- Lesson 11
- Lesson 12
- Lesson 13
- Lesson 14
-
Lesson 15
-
Steps for working on a script someone has given you
- Work on a copy of the original script
- Use your copy of Programming Perl
- Add comments
- Save versions of your changes
- Give variables meaningful names
-
Add
use warnings; -
Add
use strict; - Test the script with a small data set
- Break the code into manageable subunits
- Experiment with code fragments
-
Add
print()statements - Step through the code with the Perl debugger
- Consult your local Perl expert
-
Steps for working on a script someone has given you