Full HTML for

Basic foilset Introduction to Perl Programming: a Stroll Through Perl

Given by Nancy J. McCracken at Jackson State University Mississippi on Fall Semester 97. Foils prepared 3 Sept 1997
Outside Index Summary of Material


Text: Learning PERL (the Llama book), 2nd ed., Randal L. Schwartz, OšReilly & Associates, 1997.
PERL4 is an interpreted language that can be regarded as a cross between C, Unix shell, sed and awk. It is a C-based language which can also deal directly with Unix commands and file system and easily do string processing matching.
In this course, we will concentrate not on using PERL in systems programming, but in using PERL for CGI programming, i.e. implementing programs activated from Web pages.
In general, we use PERL for tedious high level things which can take a long time to program but not much execution time. For computationally intense programs, we would use a compiled language such as C.
Our first lecture on Perl will show a series of small programming examples from Chapter 1 of the Learning Perl book, designed to illustrate the main features of the language. Later we will cover each topic in more detail.

Table of Contents for full HTML of Introduction to Perl Programming: a Stroll Through Perl

Denote Foils where Image Critical
Denote Foils where HTML is sufficient

1 Introduction to PERL Programming:
a Stroll Through Perl
from "Learning Perl", 2nd ed. by Randal L. Schwartz

2 PERL4
3 The Simplest Program: Hello, World!
4 Scalar Variables and Keyboard Input
5 Conditional and Comparison
6 While Loop
7 Arrays, also known as lists
8 Associative arrays
9 Regular Expressions and String Matching
10 Substitute and Translate Operators
11 Subroutines
12 Reading Files
13 Sending commands to the operating system
14 Formatting output and using file names
15 Further Topics

Outside Index Summary of Material



HTML version of Basic Foils prepared 3 Sept 1997

Foil 1 Introduction to PERL Programming:
a Stroll Through Perl
from "Learning Perl", 2nd ed. by Randal L. Schwartz

From Introduction to Perl Jackson State University Mississippi -- Fall Semester 97. *
Full HTML Index
Nancy McCracken
NPAC
Syracuse University
111 College Place
Syracuse NY 13244-4100
September 5, 1997
Click here for body text

HTML version of Basic Foils prepared 3 Sept 1997

Foil 2 PERL4

From Introduction to Perl Jackson State University Mississippi -- Fall Semester 97. *
Full HTML Index
Text: Learning PERL (the Llama book), 2nd ed., Randal L. Schwartz, OšReilly & Associates, 1997.
PERL4 is an interpreted language that can be regarded as a cross between C, Unix shell, sed and awk. It is a C-based language which can also deal directly with Unix commands and file system and easily do string processing matching.
In this course, we will concentrate not on using PERL in systems programming, but in using PERL for CGI programming, i.e. implementing programs activated from Web pages.
In general, we use PERL for tedious high level things which can take a long time to program but not much execution time. For computationally intense programs, we would use a compiled language such as C.
Our first lecture on Perl will show a series of small programming examples from Chapter 1 of the Learning Perl book, designed to illustrate the main features of the language. Later we will cover each topic in more detail.

HTML version of Basic Foils prepared 3 Sept 1997

Foil 3 The Simplest Program: Hello, World!

From Introduction to Perl Jackson State University Mississippi -- Fall Semester 97. *
Full HTML Index
Each Perl program is in a Unix file, with executable permission, and is executed by typing the name of the file as a command.

HTML version of Basic Foils prepared 3 Sept 1997

Foil 4 Scalar Variables and Keyboard Input

From Introduction to Perl Jackson State University Mississippi -- Fall Semester 97. *
Full HTML Index
This program uses a scalar variable, which always starts with a $, prompts for input, reads the name, and prints hello.

HTML version of Basic Foils prepared 3 Sept 1997

Foil 5 Conditional and Comparison

From Introduction to Perl Jackson State University Mississippi -- Fall Semester 97. *
Full HTML Index
This program prints a special greeting for Randal, and an ordinary one for everybody else.

HTML version of Basic Foils prepared 3 Sept 1997

Foil 6 While Loop

From Introduction to Perl Jackson State University Mississippi -- Fall Semester 97. *
Full HTML Index
This program asks everyone, except for Randal, for a secret password.

HTML version of Basic Foils prepared 3 Sept 1997

Foil 7 Arrays, also known as lists

From Introduction to Perl Jackson State University Mississippi -- Fall Semester 97. *
Full HTML Index
This program uses an array variable, which must start with @, to hold several secret passwords.

HTML version of Basic Foils prepared 3 Sept 1997

Foil 8 Associative arrays

From Introduction to Perl Jackson State University Mississippi -- Fall Semester 97. *
Full HTML Index
Associative arrays, variables start with %, are tables with keywords and values and are used here to give each person their own password.

HTML version of Basic Foils prepared 3 Sept 1997

Foil 9 Regular Expressions and String Matching

From Introduction to Perl Jackson State University Mississippi -- Fall Semester 97. *
Full HTML Index
Accept input name in varying formats by matching strings that are case insensitive and longer, such as Randal L. Schwartz

HTML version of Basic Foils prepared 3 Sept 1997

Foil 10 Substitute and Translate Operators

From Introduction to Perl Jackson State University Mississippi -- Fall Semester 97. *
Full HTML Index
Truncate all input names to the first name and translate to all lower case.

HTML version of Basic Foils prepared 3 Sept 1997

Foil 11 Subroutines

From Introduction to Perl Jackson State University Mississippi -- Fall Semester 97. *
Full HTML Index
All subroutines in Perl have parameters and return a result, the value of the last expression before the return. Undeclared names refer to names in the outer program (global). The subroutine is called with its parameters, for example good_word($name,$guess);

HTML version of Basic Foils prepared 3 Sept 1997

Foil 12 Reading Files

From Introduction to Perl Jackson State University Mississippi -- Fall Semester 97. *
Full HTML Index
A file (or I/O channel) is referred to by a "filehandle". (Perl automatically creates filehandles STDIN, STDOUT and STDERR.) We choose to keep our password table in a file with one word per line, alternating keys and values.

HTML version of Basic Foils prepared 3 Sept 1997

Foil 13 Sending commands to the operating system

From Introduction to Perl Jackson State University Mississippi -- Fall Semester 97. *
Full HTML Index
If the wrong person guesses a password, we can send a mail message by issuing the mail command. The pipe symbol is used in the file name to indicate a command.

HTML version of Basic Foils prepared 3 Sept 1997

Foil 14 Formatting output and using file names

From Introduction to Perl Jackson State University Mississippi -- Fall Semester 97. *
Full HTML Index
A format statement can be associated with each file handle and used for writing to that channel. The format name is the name of the file handle - there can can also be another special format for labelling the tops of output pages.

HTML version of Basic Foils prepared 3 Sept 1997

Foil 15 Further Topics

From Introduction to Perl Jackson State University Mississippi -- Fall Semester 97. *
Full HTML Index
Further examples in Chapter 1 of Learning Pearl discuss
  • renaming files
  • keeping an associative table in a file database
Final programs are on page 28.

© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Sat Sep 6 1997