| |
| |
From the Editor | |
| |
| |
About the Author | |
| |
| |
Introduction | |
| |
| |
| |
Getting Started | |
| |
| |
| |
Running Perl from the Command LIne | |
| |
| |
| |
Check your Perl Version Number | |
| |
| |
| |
Run a Simple Script from the Command Line | |
| |
| |
| |
Use Perl to Process a File | |
| |
| |
| |
Writing Your First Perl Program | |
| |
| |
| |
Save and Run a Perl Script in a File | |
| |
| |
| |
Make the Script Self-Executable | |
| |
| |
| |
Test Your Thinking | |
| |
| |
| |
The Nickel Tour | |
| |
| |
| |
Comments, Command Line, Environment | |
| |
| |
| |
Use Comments, Two Types | |
| |
| |
| |
Use Command-Line Arguments | |
| |
| |
| |
Use Environment Variables | |
| |
| |
| |
Keyboard and System Commands | |
| |
| |
| |
Read Input from the Console Keyboard | |
| |
| |
| |
Run a System Command | |
| |
| |
| |
Read Input from a System Command | |
| |
| |
| |
Reading Quickly from a File | |
| |
| |
| |
Read from Files Named on the Command Line | |
| |
| |
| |
Read from a Single Named File | |
| |
| |
| |
Printing Lengthy Messages | |
| |
| |
| |
Test Your Thinking | |
| |
| |
| |
Variables: Large and Small | |
| |
| |
| |
Identifier Names and Scalar Variables | |
| |
| |
| |
Declare and Initialize Scalar Variables | |
| |
| |
| |
Write a Short Program Using Variables | |
| |
| |
| |
Simple Operators | |
| |
| |
| |
Predict the Behavior of Simple Operators | |
| |
| |
| |
Write a Simple Program That Does Calculations | |
| |
| |
| |
Scalars and Context | |
| |
| |
| |
Test Variable Context in a Short Program | |
| |
| |
| |
Use Perl's Early Warning Mode | |
| |
| |
| |
Special Scalar Variables | |
| |
| |
| |
Analyze a Program That Uses Special Variables | |
| |
| |
| |
Create Standardized Error Messages | |
| |
| |
| |
Test Your Thinking | |
| |
| |
| |
Arrays and Lists | |
| |
| |
| |
Using Arrays and lists | |
| |
| |
| |
Create a List and an Array | |
| |
| |
| |
Use an Array | |
| |
| |
| |
Using sort on an array | |
| |
| |
| |
Traversing an Array or List | |
| |
| |
| |
Traverse an array | |
| |
| |
| |
Traverse the Elements of a List | |
| |
| |
| |
Reverse the Order of Data in an Array | |
| |
| |
| |
Functions that Operate on Arrays | |
| |
| |
| |
Use an Array as a Stack | |
| |
| |
| |
Use an Array as a Queue | |
| |
| |
| |
Splicing Things; Arrays and Strings | |
| |
| |
| |
Test Your Thinking | |
| |
| |
| |
Hashes: Our Things Should Have Names | |
| |
| |
| |
Creating and Accessing a Hash | |
| |
| |
| |
Fully Initialize a Hash | |
| |
| |
| |
Add and Remove Elements in a Hash | |
| |
| |
| |
Populate a Hash from the Contents of a File | |
| |
| |
| |
Traversing a Hash | |
| |
| |
| |
Traverse a Hash in Arbitrary Order | |
| |
| |
| |
Traverse in Order by Key or Value | |
| |
| |
| |
Use the environment hash | |
| |
| |
| |
Test Your Thinking | |
| |
| |
| |
Tests and Branching | |
| |
| |
| |
Truth, Branching, and the Many Faces of Nothing | |
| |
| |
| |
Conditional Execution | |
| |
| |
| |
Combine Conditions | |
| |
| |
| |
Use the Logical Negation Operator | |
| |
| |
| |
Traditional Branching Constructs | |
| |
| |
| |
Conditionally Execute Entire Blocks of Code | |
| |
| |
| |
Use the Short-Circuit Operator | |
| |
| |
| |
Use the Conditional Operator | |
| |
| |
| |
Tests That Involve Numbers, Strings, and Files | |
| |
| |
| |
Conduct Arithmetic Comparison Tests | |
| |
| |
| |
Conduct String Comparison Tests | |
| |
| |
| |
Conduct File Status Tests | |
| |
| |
| |
Test Your Thinking | |
| |
| |
| |
Regular Expressions | |
| |
| |
| |
Standard Regular Expression Metacharacters | |
| |
| |
| |
Use Regular Expressions to Match Partial Strings | |
| |
| |
| |
Use the Match Operator with the Default Variable | |
| |
| |
| |
Use the Binding Operator to Match in Any Variable | |
| |
| |
| |
Peral Extended Metacharacters | |
| |
| |
| |
Use Perl Extended Metacharacters | |
| |
| |
| |
Use the Perl Substitution Operator | |
| |
| |
| |
Use the Perl Transliteration Operator | |
| |
| |
| |
Simulating a Switch Construct | |
| |
| |
| |
Implement a Switch Construct | |
| |
| |
| |
Write a User Shell | |
| |
| |
| |
Test Your Thinking | |
| |
| |
| |
Loops (and Other Repetitive Experiences) | |
| |
| |
| |
Traditional Loops | |
| |
| |
| |
Use While and Until Loops | |
| |
| |
| |
Use the Foreach Loop | |
| |
| |
| |
Use the For Loop | |
| |
| |
| |
Unusual Loops | |
| |
| |
| |
Use the "Looplike" Modifiers and the do{} Block | |
| |
| |
| |
Write Nested Loops | |
| |
| |
| |
Advanced Loop Control | |
| |
| |
| |
Use last/next/redo to Control Loops | |
| |
| |
| |
Write "Infinite Loops" and Use the continue{} Block | |
| |
| |
| |
Test Your Thinking | |
| |
| |
| |
Files: Outside and In | |
| |
| |
| |
File Meta-Information (File Statistics) | |
| |
| |
| |
Use stat() to Get Information About a File | |
| |
| |
| |
Reading the Contents of a Directory | |
| |
| |
| |
Compile a Report Showing Large or Old Files | |
| |
| |
| |
Functions that Manipulate Files | |
| |
| |
| |
Remove/Rename Files | |
| |
| |
| |
Create/Remove Directories | |
| |
| |
| |
Change File Owner, Group, or Permissions | |
| |
| |
| |
Opening Filehandles for Reading and Writing | |
| |
| |
| |
Open a File for Reading, Writing, or Appending | |
| |
| |
| |
Open a Pipe for Reading or Writing | |
| |
| |
| |
Open the Special DATA Filehandle | |
| |
| |
| |
Test Your Thinking | |
| |
| |
| |
Functions: Programming in Polite Society | |
| |
| |
| |
Writing and Executing Functions | |
| |
| |
| |
Declare and Call a Function | |
| |
| |
| |
Call a Function That Updates Variables | |
| |
| |
| |
Function Arguments and Return Values | |
| |
| |
| |
Pass Information to Functions as Arguments | |
| |
| |
| |
Have Functions Return Information | |
| |
| |
| |
Localize Variables to Their Function | |
| |
| |
| |
Building a Library of Functions | |
| |
| |
| |
Put Functions into a Library for Reuse | |
| |
| |
| |
Manage Library Location with @INC | |
| |
| |
| |
Test Your Thinking | |
| |
| |
| |
Ends and Odds | |
| |
| |
| |
Using POD to Embed Multi-Purpose Documentation | |
| |
| |
| |
Write POD Content to Document Your Code | |
| |
| |
| |
Produce HTML and Man Pages from POD | |
| |
| |
| |
Using format and write() for Reports | |
| |
| |
| |
Use format and write() to Create a Report | |
| |
| |
| |
Use Advanced Report Features | |
| |
| |
| |
Using Perl Modules | |
| |
| |
| |
Use a Perl Module to Parse Command Lines | |
| |
| |
| |
Use a Perl Module to Recurse a Directory Tree | |
| |
| |
| |
Test Your Thinking | |
| |
| |
| |
Answers to Self-Review Questions | |
| |
| |
| |
Perl Reference | |
| |
| |
Index | |