Minimal Perl BOF, #2
[email protected] (Tim Maher/CONSULTIX)
| Newsgroups | perl.trainers |
|---|---|
| Message-ID | <[email protected]> |
Perl-trainers,
Sorry if you've already seen this; I see posts from others to this
list, but I didn't see my own come through. Trying again.
-Tim
FYI Trainers,
> Tim Maher, your "Minimal Perl for the Impatient" BOF has
> been scheduled for:
> Date: Wednesday, July 25
> Time: 9-10 pm
> Location: Grande Ballroom A (East)
> Topic: Minimal Perl for the Impatient
> Moderator: Tim Maher, Consultix
> Summary:
> Many beginners don't want "More Than One Way to Do
> It", just the "Easiest Way". Tim's "Minimal Perl"
> dialect, based on AWK's "Pattern/Action" model,
> covers the necessary skills for writing File
> Conversion, Data Validation, and Report Generation
> programs. He'll describe the current dialect, and
> then lead a brainstorming session about possible
> improvements to make Perl even more accessible to
> newbies.
<More Background>
I was surprised at the large turnout for my SPUG talk
earlier this week, in which I introduced my "Minimal
Perl" dialect for beginners. It was unusually large
(nearly 40) for a "standard speaker" (me) during great
Seattle summer weather (not unusual; I MEAN, it always
rains, don't move here!). I thought at first they might
have been expecting some wacky Aussie bloke instead
(that's next month), but there was no mistake, they
were "minimalists" with strong Perl cravings!
This confirmed my notion that there are many people out
there who would like to learn some Perl, but feel put
off by the complexity and "eccentricity", shall I say,
of the language. So I'm working on a distillation
of the most powerful but easy to understand and use
features, to define a new "dialect", in the hope of
making things easier for many newbies. (Guess what!
So far, it looks a lot like AWK -- but with better
regexes!)
Just wanted to let you all know that I've scheduled a
BOF on this subject for TPC on Wednesday night, 9-10,
and I'd be very grateful to hear the ideas of other
Perl trainers on this subject. (I know that clashes
with Nat's JAM BOF, but I had no choice, sorry!)
Somewhat along these lines, but with different goals,
I'm also interested in talking about having the
compiler enforce 2 or 3 dialects of Perl (e.g., Basic,
Intermediate, Advanced) in part to make MIS managers
more comfortable about the possibility of having one
programmer maintain code written by another. The other
reason is to make newbie mistakes like the following
compile-time errors;
@A={ 'a', 'b' } ; # Warning: odd number of initializers!
I know the idea of "graded" language levels has also occurred
to Nat, and probably to other trainers who work in the corporate
world, so I'd like to discuss this too at the BOF.
(By the way, one recent breakthrough in the area of
"MIS Manager consolation" is that we've got a
good beautifier now, "Perltidy", so programmers can
at least apprehend the basic structure of each other's
programs.)
I've also attached a description of my YAPC::Europe
talk on Minimal Perl, which offers more details.
Hope to see many of you at the BOF!
-Tim
========================================================
| Tim Maher, Ph.D. Tel: (206) 781-UNIX |
| SPUG Founder & Leader Email: [email protected] |
| Seattle Perl Users Group HTTP: seattleperl.com |
========================================================
minperl.att
(text/plain, 6.1 KB)
TITLE: Minimal Perl for the Impatient
Length: 1 day, Hands-On
SPEAKER: Dr. Tim Maher
[email protected]
Head Software Instructor
CONSULTIX, POB 70563, Seattle WA 98107
http://www.consultix-inc.com
(206) 781-UNIX/8649
Target Audience
Anyone who doesn't already know Perl, needs to do simple data
processing, and has a logical mindset can benefit from attending.
This class is particularly well suited to individuals of the
following types:
o Non-Programmers (MIS managers, etc.),
who want to gain a better understanding of why Perl is so popular
with professional programmers, and learn to do basic data
processing without learning too much or thinking too hard,
o Near-Programmers,
who are handy with the "grep", "sed", or "awk" commands, and want
to expand their skills to include the premier "programmable
filter", AND
o Programmers,
who don't want to learn enough to become Perl experts, but just
enough to gain access to some of its special capabilities.
Prerequisites
Prior experience with programming is helpful, but anyone with a
logical mindset can benefit from attending.
Course Philosophy
Perl is a wonderful language, that offers programmers a rich feature
set, huge stylistic and syntactic liberties, and many ways to
accomplish the same thing. But for the impatient beginner, these
characteristics can translate into "too many complications, too much
uncertainty, and too many choices." Although Perl's motto is "There's
More Than One Way to Do It", this class will teach students only
one way -- the "Easiest Way"!
What Attendees Will Learn
Students will learn a carefully selected minimal subset of Perl that
gives immediate access to some of its powerful capabilities, and
serves as a solid foundation for additional learning. The class's
approach is based on the "Pattern/Action" model of programming, as
featured in the influential AWK language.
Upon completion of the class, students will have the necessary
skills to convert files, validate data, generate simple reports, and
perform numerical calculations in Perl.
Author & Instructor
During the last two decades, Dr. Tim Maher has taught programming to
thousands of high-tech professionals. As a Professor of Computer
Science, and later as a Software Instructor for AT&T, Sun, DEC, HP,
and CONSULTIX, Dr. Maher has consistently earned acclaim for his
highly effective and entertaining style of course development and
presentation.
COURSE OUTLINE
1. Course Introduction
Course Objectives
2. Creating a Perl Script
Using the print Function
Using Double-Quotes
Using "\n"
Creating the File
Enabling Appropriate Options
-w Option
-n Option
-l Option
-i Option
use English;
Making the Script Executable and Locatable
Windows Example
UNIX/Linux Example
Submitting Script to Operating System
Windows Example
UNIX/Linux Example
The "Hello, World!" Program
Lesson Review
3. Pre- and Post-Input Processing
The BEGIN Block
The END Block
Lesson Review
4. Accessing Inputs
Named Files
Default Input Source
Accessing Input Lines
The $ARG Variable (aka $_)
Lesson Review
5. Operators and Branching
String Operators
Using "eq" and "ne"
Numeric Operators
Using "==" and "!="
Using ">", "<", ">=", "<="
Arithmetic Operators
Using "+", "-", "*", "/"
Compound Tests
Using Logical "and" And "or"
Importance of Parentheses
Pattern/Action Syntax
The if Statement
The if/else Statement
Example: Working with Selected Input Lines
Lesson Review
6. Using Variables
Perl Variables
Output Field Separator: $OFS (aka $,)
Input Record Separator: $RS (aka $/)
Output Record Separator: $ORS (aka $\)
Number of Current Record: $NR (aka $.)
Number of Fields: @F
User-Defined Variables
As Data Storage/Retrieval Tools
Lesson Review
7. Matching Patterns and Performing Substitutions
The Matching Operator
Using the /i Option
The Substitution Operator
Using the /i Option
Using the /g Option
Example: Selecting Lines with Matches
Example: Performing Substitutions on Matched Text
Lesson Review
8. Elementary Regular Expressions (REs)
What is a Regular Expression?
Literal Characters
Meta-Characters
Anchoring Metacharacters: ^, $, \b
The One-Character Wildcard: .
The Enumerated Wildcard (Character Class): []
Repetition Metacharacters: *, +
The "Anything Goes" Metacharacter: .*
The Quoting Metacharacter: \
Avoiding Common Blunders
Lesson Review
9. Working with Fields
Using the -a Option
Default Field Separators
Custom Field Separators
Using the -F'[]+' Option
Field and Record Variables
$F[0], $F[1], etc.
Lesson Review
10. Course Conclusion
Additional Code Samples
Review and Summary
Where to Learn More