Home Page Icon
Home Page
Table of Contents for
Cover
Close
Cover
by Randal L. Schwartz, Tom Phoenix
Learning Perl, 3rd Edition
A Note Regarding Supplemental Files
Preface
Typographical Conventions
How to Contact Us
Code Examples
History of This Book
Acknowledgments
1. Introduction
1.1. Questions and Answers
1.1.1. Is This the Right Book for You?
1.1.2. Why Are There So Many Footnotes?
1.1.3. What About the Exercises and Their Answers?
1.1.4. What Do Those Numbers Mean at the Start of the Exercise?
1.1.5. What If I’m a Perl Course Instructor?
1.2. What Does “Perl” Stand For?
1.2.1. Why Didn’t Larry Just Use Some Other Language?
1.2.2. Is Perl Easy or Hard?
1.2.3. How Did Perl Get to Be So Popular?
1.2.4. What’s Happening with Perl Now?
1.2.5. What’s Perl Really Good For?
1.2.6. What Is Perl Not Good For?
1.3. How Can I Get Perl?
1.3.1. What Is CPAN?
1.3.2. How Can I Get Support for Perl?
1.3.3. Are There Any Other Kinds of Support?
1.3.4. What If I Find a Bug in Perl?
1.4. How Do I Make a Perl Program?
1.4.1. A Simple Program
1.4.2. What’s Inside That Program?
1.4.3. But How Do I Compile Perl?
1.5. A Whirlwind Tour of Perl
1.6. Exercises
2. Scalar Data
2.1. What Is Scalar Data?
2.2. Numbers
2.2.1. All Numbers Are the Same Format Internally
2.2.2. Floating-Point Literals
2.2.3. Integer Literals
2.2.4. Nondecimal Integer Literals
2.2.5. Numeric Operators
2.3. Strings
2.3.1. Single-Quoted String Literals
2.3.2. Double-Quoted String Literals
2.3.3. String Operators
2.3.4. Automatic Conversion Between Numbers and Strings
2.4. Perl’s Built-in Warnings
2.5. Scalar Variables
2.5.1. Choosing Good Variable Names
2.5.2. Scalar Assignment
2.5.3. Binary Assignment Operators
2.6. Output with print
2.6.1. Interpolation of Scalar Variables into Strings
2.6.2. Operator Precedence and Associativity
2.6.3. Comparison Operators
2.7. The if Control Structure
2.7.1. Boolean Values
2.8. Getting User Input
2.9. The chomp Operator
2.10. The while Control Structure
2.11. The undef Value
2.12. The defined Function
2.13. Exercises
3. Lists and Arrays
3.1. Accessing Elements of an Array
3.2. Special Array Indices
3.3. List Literals
3.3.1. The qw Shortcut
3.4. List Assignment
3.4.1. The pop and push Operators
3.4.2. The shift and unshift Operators
3.5. Interpolating Arrays into Strings
3.6. The foreach Control Structure
3.7. Perl’s Favorite Default: $_
3.7.1. The reverse Operator
3.7.2. The sort Operator
3.8. Scalar and List Context
3.8.1. Using List-Producing Expressions in Scalar Context
3.8.2. Using Scalar-Producing Expressions in List Context
3.8.3. Forcing Scalar Context
3.9. <STDIN> in List Context
3.10. Exercises
4. Subroutines
4.1. System and User Functions
4.2. Defining a Subroutine
4.3. Invoking a Subroutine
4.4. Return Values
4.5. Arguments
4.6. Private Variables in Subroutines
4.7. The local Operator
4.7.1. The Difference Between local and my
4.8. Variable-length Parameter Lists
4.8.1. A Better &max Routine
4.8.2. Empty Parameter Lists
4.9. Notes on Lexical (my) Variables
4.10. The use strict Pragma
4.11. The return Operator
4.11.1. Omitting the Ampersand
4.12. Exercises
5. Hashes
5.1. What Is a Hash?
5.1.1. Why Use a Hash?
5.2. Hash Element Access
5.2.1. The Hash as a Whole
5.2.2. Hash Assignment
5.2.3. The Big Arrow
5.3. Hash Functions
5.3.1. The keys and values Functions
5.3.2. The each Function
5.4. Typical Use of a Hash
5.4.1. The exists Function
5.4.2. The delete Function
5.4.3. Hash Element Interpolation
5.5. Exercises
6. I/O Basics
6.1. Input from Standard Input
6.2. Input from the Diamond Operator
6.3. The Invocation Arguments
6.4. Output to Standard Output
6.5. Formatted Output with printf
6.5.1. Arrays and printf
6.6. Exercises
7. Concepts of Regular Expressions
7.1. What Are Regular Expressions?
7.2. Using Simple Patterns
7.2.1. About Metacharacters
7.2.2. Simple Quantifiers
7.2.3. Grouping in Patterns
7.2.4. Alternatives
7.3. A Pattern Test Program
7.4. Exercises
8. More About Regular Expressions
8.1. Character Classes
8.1.1. Character Class Shortcuts
8.1.2. Negating the Shortcuts
8.2. General Quantifiers
8.3. Anchors
8.3.1. Word Anchors
8.4. Memory Parentheses
8.4.1. Backreferences
8.4.2. Memory Variables
8.5. Precedence
8.5.1. Examples of Precedence
8.5.2. And There’s More
8.6. Exercises
9. Using Regular Expressions
9.1. Matches with m//
9.2. Option Modifiers
9.2.1. Case-insensitive Matching with /i
9.2.2. Matching Any Character with /s
9.2.3. Combining Option Modifiers
9.2.4. Other Options
9.3. The Binding Operator, =~
9.4. Interpolating into Patterns
9.5. The Match Variables
9.5.1. The Persistence of Memory
9.5.2. The Automatic Match Variables
9.6. Substitutions with s///
9.6.1. Global Replacements with /g
9.6.2. Different Delimiters
9.6.3. Option Modifiers
9.6.4. The Binding Operator
9.6.5. Case Shifting
9.7. The split Operator
9.8. The join Function
9.9. Exercises
10. More Control Structures
10.1. The unless Control Structure
10.1.1. The else Clause with unless
10.2. The until Control Structure
10.3. Expression Modifiers
10.4. The Naked Block Control Structure
10.5. The elsif Clause
10.6. Autoincrement and Autodecrement
10.6.1. The Value of Autoincrement
10.7. The for Control Structure
10.7.1. The Secret Connection Between foreach and for
10.8. Loop Controls
10.8.1. The last Operator
10.8.2. The next Operator
10.8.3. The redo Operator
10.8.4. Labeled Blocks
10.9. Logical Operators
10.9.1. The Value of a Short-Circuit Operator
10.9.2. The Ternary Operator, ?:
10.9.3. Control Structures Using Partial-Evaluation Operators
10.10. Exercise
11. Filehandles and File Tests
11.1. What Is a Filehandle?
11.2. Opening a Filehandle
11.2.1. Closing a Filehandle
11.2.2. Bad Filehandles
11.3. Fatal Errors with die
11.3.1. Warning Messages with warn
11.4. Using Filehandles
11.4.1. Changing the Default Output Filehandle
11.5. Reopening a Standard Filehandle
11.6. File Tests
11.6.1. The stat and lstat Functions
11.6.2. The localtime Function
11.6.3. Bitwise Operators
11.6.4. Using Bitstrings
11.6.5. Using the Special Underscore Filehandle
11.7. Exercises
12. Directory Operations
12.1. Moving Around the Directory Tree
12.2. Globbing
12.3. An Alternate Syntax for Globbing
12.4. Directory Handles
12.5. Recursive Directory Listing
12.6. Exercises
13. Manipulating Files and Directories
13.1. Removing Files
13.2. Renaming Files
13.3. Links and Files
13.4. Making and Removing Directories
13.5. Modifying Permissions
13.6. Changing Ownership
13.7. Changing Timestamps
13.8. Using Simple Modules
13.8.1. The File::Basename Module
13.8.2. Using Only Some Functions from a Module
13.8.3. The File::Spec Module
13.9. Exercises
14. Process Management
14.1. The system Function
14.1.1. Avoiding the Shell
14.2. The exec Function
14.3. The Environment Variables
14.4. Using Backquotes to Capture Output
14.4.1. Using Backquotes in a List Context
14.5. Processes as Filehandles
14.6. Getting Down and Dirty with Fork
14.7. Sending and Receiving Signals
14.8. Exercises
15. Strings and Sorting
15.1. Finding a Substring with index
15.2. Manipulating a Substring with substr
15.3. Formatting Data with sprintf
15.3.1. Using sprintf with “Money Numbers”
15.4. Advanced Sorting
15.4.1. Sorting a Hash by Value
15.4.2. Sorting by Multiple Keys
15.5. Exercises
16. Simple Databases
16.1. DBM Files and DBM Hashes
16.1.1. Opening and Closing DBM Hashes
16.1.2. Using a DBM Hash
16.2. Manipulating Data with pack and unpack
16.3. Fixed-length Random-access Databases
16.4. Variable-length (Text) Databases
16.4.1. In-place Editing from the Command Line
16.5. Exercises
17. Some Advanced Perl Techniques
17.1. Trapping Errors with eval
17.2. Picking Items from a List with grep
17.3. Transforming Items from a List with map
17.4. Unquoted Hash Keys
17.5. More Powerful Regular Expressions
17.5.1. Non-greedy Quantifiers
17.5.2. Matching Multiple-line Text
17.6. Slices
17.6.1. Array Slice
17.6.2. Hash Slice
17.7. Exercise
A. Exercise Answers
A.1. Answers to Chapter 2 Exercises
A.2. Answers to Chapter 3 Exercises
A.3. Answers to Chapter 4 Exercises
A.4. Answers to Chapter 5 Exercises
A.5. Answers to Chapter 6 Exercises
A.6. Answers to Chapter 7 Exercises
A.7. Answers to Chapter 8 Exercises
A.8. Answers to Chapter 9 Exercises
A.9. Answer to Chapter 10 Exercise
A.10. Answers to Chapter 11 Exercises
A.11. Answers to Chapter 12 Exercises
A.12. Answers to Chapter 13 Exercises
A.13. Answers to Chapter 14 Exercises
A.14. Answers to Chapter 15 Exercises
A.15. Answers to Chapter 16 Exercises
A.16. Answer to Chapter 17 Exercises
B. Beyond the Llama
B.1. Further Documentation
B.2. Regular expressions
B.3. Packages
B.4. Extending Perl’s Functionality
B.4.1. Libraries
B.4.2. Modules
B.4.3. Finding and Installing Modules
B.4.4. Writing Your Own Modules
B.5. Some Important Modules
B.5.1. The CGI and CGI_Lite Modules
B.5.2. The Cwd Module
B.5.3. The Fatal Module
B.5.4. The File::Basename Module
B.5.5. The File::Copy Module
B.5.6. The File::Spec Module
B.5.7. The Image::Size Module
B.5.8. The Net::SMTP Module
B.5.9. The POSIX Module
B.5.10. The Sys::Hostname Module
B.5.11. The Text::Wrap Module
B.5.12. The Time::Local Module
B.6. Pragmas
B.6.1. The constant Pragma
B.6.2. The diagnostics Pragma
B.6.3. The lib Pragma
B.6.4. The strict Pragma
B.6.5. The vars Pragma
B.6.6. The warnings Pragma
B.7. Databases
B.7.1. Direct System Database Access
B.7.2. Flat-file Database Access
B.7.3. Relational Database Access
B.8. Other Operators and Functions
B.8.1. Transliteration with tr///
B.8.2. Here documents
B.9. Mathematics
B.9.1. Advanced Math Functions
B.9.2. Imaginary and Complex Numbers
B.9.3. Large and High-Precision Numbers
B.10. Lists and Arrays
B.10.1. map and grep
B.10.2. The splice Operator
B.11. Bits and Pieces
B.12. Formats
B.13. Networking and IPC
B.13.1. System V IPC
B.13.2. Sockets
B.14. Security
B.15. Debugging
B.16. The Common Gateway Interface (CGI)
B.17. Command-Line Options
B.18. Built in Variables
B.19. Syntax Extensions
B.20. References
B.20.1. Complex Data Structures
B.20.2. Object-Oriented Programming
B.20.3. Anonymous Subroutines and Closures
B.21. Tied Variables
B.22. Operator Overloading
B.23. Dynamic Loading
B.24. Embedding
B.25. Converting Other Languages to Perl
B.26. Converting find Command Lines to Perl
B.27. Command-line Options in Your Programs
B.28. Embedded Documentation
B.29. More Ways to Open Filehandles
B.30. Locales and Unicode
B.31. Threads and Forking
B.32. Graphical User Interfaces (GUIs)
B.33. And More...
Index
About the Authors
Colophon
Copyright
Search in book...
Toggle Font Controls
Playlists
Add To
Create new playlist
Name your new playlist
Playlist description (optional)
Cancel
Create playlist
Sign In
Email address
Password
Forgot Password?
Create account
Login
or
Continue with Facebook
Continue with Google
Sign Up
Full Name
Email address
Confirm Email Address
Password
Login
Create account
or
Continue with Facebook
Continue with Google
Next
Next Chapter
Learning Perl, 3rd Edition
Add Highlight
No Comment
..................Content has been hidden....................
You can't read the all page of ebook, please click
here
login for view all page.
Day Mode
Cloud Mode
Night Mode
Reset