| |
| |
Introduction | |
| |
| |
| |
Introducing Perl | |
| |
| |
| |
Perl Basics | |
| |
| |
Project Preview: The Perl Humor Script | |
| |
| |
Perl Scripting Overview | |
| |
| |
A Little Perl History | |
| |
| |
Where's Perl 6? | |
| |
| |
What Can Perl Scripts Do? | |
| |
| |
The Programming Language, the Interpreter, and Scripts | |
| |
| |
Working from the Command Prompt | |
| |
| |
Accessing the Command Prompt on Windows XP | |
| |
| |
Accessing the Command Prompt on Mac OS X | |
| |
| |
Accessing the Command Prompt in Unix and Linux | |
| |
| |
Not Everything Smells Like Roses | |
| |
| |
Determining if Perl Is Installed on Your Computer | |
| |
| |
Where to Find Perl | |
| |
| |
Where to Find Perl's Documentation | |
| |
| |
Perldoc | |
| |
| |
Man Pages | |
| |
| |
ActiveState Documentation | |
| |
| |
Writing Your First Perl Scripts | |
| |
| |
Creating Perl One-liners | |
| |
| |
Writing Your First Perl Script File | |
| |
| |
Dissecting Hello.pl | |
| |
| |
How Perl Executes Your Script | |
| |
| |
Back to the Perl Humor Script | |
| |
| |
Designing the Game | |
| |
| |
The Final Result | |
| |
| |
Summary | |
| |
| |
| |
Working with Strings, Numbers, and Operators | |
| |
| |
Project Preview: The Story of William the Great | |
| |
| |
Perl's Free-Wheeling Approach to Code Structure | |
| |
| |
Perl's Flexible View of Data | |
| |
| |
Working with Strings | |
| |
| |
Working with Numbers | |
| |
| |
Converting Scalar Data | |
| |
| |
Storing Data in Scalar Variables | |
| |
| |
Variable Scope | |
| |
| |
Assigning Data to Scalar Variables | |
| |
| |
Variable Interpolation | |
| |
| |
Understandings How to Work with Perl Operators | |
| |
| |
String Operators | |
| |
| |
Arithmetic Operators | |
| |
| |
Increment and Decrement Operators | |
| |
| |
Assignment Operators | |
| |
| |
Relational Operators | |
| |
| |
Logical Operators | |
| |
| |
Input and Output | |
| |
| |
Working with Standard Input | |
| |
| |
Working with Standard Output | |
| |
| |
Back to the Story of William the Great | |
| |
| |
Designing the Game | |
| |
| |
The Final Result | |
| |
| |
Summary | |
| |
| |
| |
Mastering Key Perl Programming Constructs | |
| |
| |
| |
Controlling Program Flow | |
| |
| |
Project Preview: The Perl Fortune Teller Game | |
| |
| |
Code Blocks | |
| |
| |
Applying Conditional Logic | |
| |
| |
Perl's View of What's True and False | |
| |
| |
Variations of the if Statement | |
| |
| |
The unless Statement | |
| |
| |
Creating More Sophisticated Conditional Logic | |
| |
| |
Nesting | |
| |
| |
Working with the ?...: Conditional Operator | |
| |
| |
Creating Custom Conditional Structures | |
| |
| |
Setting Up Loops | |
| |
| |
While | |
| |
| |
Until | |
| |
| |
Do | |
| |
| |
For | |
| |
| |
Foreach | |
| |
| |
Adding Continue Blocks to Your Loops | |
| |
| |
Loop Controls | |
| |
| |
The last Statement | |
| |
| |
The next Statement | |
| |
| |
The redo Statement | |
| |
| |
Adding Labels to Your Code Blocks and Loops | |
| |
| |
Back to the Perl Fortune Teller Game | |
| |
| |
Designing the Game | |
| |
| |
The Final Result | |
| |
| |
Summary | |
| |
| |
| |
Working with Collections of Data | |
| |
| |
Project Preview: The Star Wars Quiz | |
| |
| |
Working with Collections of Related Data | |
| |
| |
Assigning Data to a List | |
| |
| |
Working with Arrays | |
| |
| |
Declaring an Array | |
| |
| |
Populating and Modifying Arrays with Data | |
| |
| |
Retrieving Data from an Array | |
| |
| |
Sorting Array Elements | |
| |
| |
Deleting Array Elements | |
| |
| |
Using Arrays to Populate Variables and Other Arrays | |
| |
| |
Ensuring That Array Elements Exist | |
| |
| |
Dealing with Undefined Array Elements | |
| |
| |
Creating Hashes | |
| |
| |
Adding and Deleting Hash Elements | |
| |
| |
Processing Hash Contents | |
| |
| |
Sorting Hash Values | |
| |
| |
Converting Between Arrays and Hashes | |
| |
| |
Understanding Context within Perl | |
| |
| |
Scalar Context | |
| |
| |
Numeric Context | |
| |
| |
Boolean Context | |
| |
| |
Scalar Versus List Context | |
| |
| |
Context and Lists, Arrays, and Hashes | |
| |
| |
Back to the Star Wars Quiz | |
| |
| |
Designing the Game | |
| |
| |
The Final Result | |
| |
| |
Summary | |
| |
| |
| |
Improving Script Organization and Structure | |
| |
| |
Project Preview: The Pick a Number Game | |
| |
| |
Enhancing Script Organization | |
| |
| |
Organizing Perl Scripts Using Subroutines | |
| |
| |
Defining Subroutines | |
| |
| |
Executing Subroutines | |
| |
| |
A Template for Organizing Your Scripts and Subroutines | |
| |
| |
The Fortune Teller Game Revisited | |
| |
| |
Passing Arguments to Subroutines | |
| |
| |
Passing Data to Subroutines for Processing | |
| |
| |
Accessing Subroutine Arguments | |
| |
| |
Reassigning Subroutine Arguments | |
| |
| |
Passing Lists, Arrays, and Hashes as Arguments | |
| |
| |
Getting Data Back from Subroutines | |
| |
| |
Controlling Variable Scope | |
| |
| |
Creating Private Variables | |
| |
| |
Getting Strict with Private Variables | |
| |
| |
Creating Local Variables | |
| |
| |
Back to the Pick a Number Game | |
| |
| |
Designing the Game | |
| |
| |
The Final Result | |
| |
| |
Summary | |
| |
| |
| |
Scope and Modules | |
| |
| |
Project Preview: The Rock, Paper, Scissors Game | |
| |
| |
Exercising Additional Control over Variable Scope | |
| |
| |
Working with Perl Modules | |
| |
| |
The Perl Library | |
| |
| |
Accessing Module Documentation | |
| |
| |
Importing Modules into Perl Scripts | |
| |
| |
Building Custom Modules | |
| |
| |
Defining a New Perl Module | |
| |
| |
Saving Your Custom Modules | |
| |
| |
Importing and Using Custom Perl Modules | |
| |
| |
Using Other People's Perl Modules | |
| |
| |
PPM | |
| |
| |
CPAN | |
| |
| |
Back to the Rock, Paper, Scissors Game | |
| |
| |
Building the Clear_the_screen Module | |
| |
| |
Designing the Game | |
| |
| |
The Final Result | |
| |
| |
Summary | |
| |
| |
| |
Advanced Topics | |
| |
| |
| |
Regular Expressions | |
| |
| |
Project Preview: The Lottery Picker Game | |
| |
| |
Introducing Regular Expressions | |
| |
| |
Matching Simple Patterns | |
| |
| |
Creating Simple Patterns | |
| |
| |
Shorter Pattern Footprints | |
| |
| |
Working with Metacharacters | |
| |
| |
Matching Patterns at the Beginning of a String | |
| |
| |
Matching Patterns at the End of a String | |
| |
| |
Matching One or Fewer Times | |
| |
| |
Matching Any Single Character | |
| |
| |
Matching Zero or More Instances | |
| |
| |
Matching One or More Instances | |
| |
| |
Matching a Range of Instances | |
| |
| |
Matching Alternative Patterns | |
| |
| |
Matching Any of a Collection of Characters | |
| |
| |
Other Regular Expression Tips and Tricks | |
| |
| |
Using Patterns to Replace Data | |
| |
| |
Performing Character Translation | |
| |
| |
Handling Differences in Case | |
| |
| |
Matching Data Stored in Lists | |
| |
| |
Back to the Lottery Picker Game | |
| |
| |
Designing the Game | |
| |
| |
The Final Result | |
| |
| |
Summary | |
| |
| |
| |
Debugging | |
| |
| |
Project Preview: The Tic Tac Toe Game | |
| |
| |
Understanding Perl Script Errors | |
| |
| |
Syntax Errors | |
| |
| |
Runtime Errors | |
| |
| |
Logical Errors | |
| |
| |
Examining Perl Error Messages | |
| |
| |
Tracing Logical Flow with the Print Function | |
| |
| |
Using the Perl Debugger to Track Down Pesky Bugs | |
| |
| |
Starting the Debugger | |
| |
| |
Executing Additional Code Statements | |
| |
| |
Resuming or Restarting Execution | |
| |
| |
Tracing Logic Flow | |
| |
| |
Quitting the Debugger | |
| |
| |
Locating Your Position within the Script | |
| |
| |
Displaying and Modifying Variable Values | |
| |
| |
Displaying Help Information | |
| |
| |
Executing any Perl Statement | |
| |
| |
Setting and Working with Breakpoints | |
| |
| |
Using the Perl Debugger as an Interactive Test Environment | |
| |
| |
Using a Graphical Perl IDE/Debugger | |
| |
| |
Tips for Writing Cleaner Code | |
| |
| |
Document What Your Script Is Doing | |
| |
| |
Enable Warnings | |
| |
| |
Add Use Strict | |
| |
| |
Keep Things Simple | |
| |
| |
Break Things Down into Subroutines | |
| |
| |
Back to the Tic Tac Toe Game | |
| |
| |
Designing the Game | |
| |
| |
The Final Result | |
| |
| |
Summary | |
| |
| |
| |
Appendices | |
| |
| |
| |
Perl Scripting Examples | |
| |
| |
CGI Scripting | |
| |
| |
Creating a Basic CGI File | |
| |
| |
Executing Perl CGI Scripts | |
| |
| |
Working with the CGI.pm Module | |
| |
| |
Creating Reports and Documents | |
| |
| |
Opening Files for Reading | |
| |
| |
Reacting to Failures when Opening Files | |
| |
| |
Reading File Contents | |
| |
| |
Opening Files for Writing | |
| |
| |
Writing File Output | |
| |
| |
Closing Files when Done | |
| |
| |
Managing Files and Directories | |
| |
| |
Managing Files | |
| |
| |
Managing Directories | |
| |
| |
PerlScript and the WSH | |
| |
| |
| |
What's on the Companion Website? | |
| |
| |
The Book's Source Code | |
| |
| |
Advanced Text Editors | |
| |
| |
JGsoft EditPad Lite | |
| |
| |
JGsoft EditPad Pro | |
| |
| |
Perl Editors | |
| |
| |
Perl Code Editor | |
| |
| |
Perl Builder 2.0 | |
| |
| |
DzSoft Perl Editor | |
| |
| |
Komodo | |
| |
| |
PerlEdit | |
| |
| |
| |
What Next? | |
| |
| |
Recommended Reading | |
| |
| |
Locating Perl Resources Online | |
| |
| |
perl.com | |
| |
| |
The Perl Directory at Perl.org | |
| |
| |
Perlmonks | |
| |
| |
The Comprehensive Perl Archive Network | |
| |
| |
The Perl Foundation | |
| |
| |
Perl Mailing Lists | |
| |
| |
perl.beginners | |
| |
| |
Yahoo! Groups: perl.beginners | |
| |
| |
Glossary | |
| |
| |
Index | |