|
|
||
![]() |
||
| HELP | ||
|
This item may be
Check for Availabilityout of stock. Click on the button below to search for this title in other formats. Perl Cookbookby Tom Christiansen and Nathan Torkington
Synopses & ReviewsPublisher Comments:The Perl Cookbook is a comprehensive collection of problems, solutions, and practical examples for anyone programming in Perl. Topics range from beginner questions to techniques that even the most experienced of Perl programmers will learn from. More than just a collection of tips and tricks, the Perl Cookbook is the long-awaited companion volume to Programming Perl, filled with previously unpublished Perl arcana. The Perl Cookbook contains thousands upon thousands of examples ranging from brief one-liners to complete applications. Covered topic areas spread across nearly four hundred separate "recipes," including:
These recipes were rigorously reviewed by scores of the best minds inside and outside Perl, foremost of which was Larry Wall, the creator of Perl himself. The Perl Cookbook is written by Tom Christiansen, Perl evangelist and coauthor of the bestselling Programming Perl and Learning Perl; and Nathan Torkington, Perl trainer and co-maintainer of the Perl Frequently Asked Questions list. Book News Annotation:Two experienced Perl writers present a collection of problems,
solutions, and practical examples for Perl programmers. Topics range
from beginner questions to techniques for experienced programmers.
Covered topics include manipulation of strings, numbers, dates, and
hashes, reading and writing text and binary files, pattern matching
and text substitutions, and signals and exceptions. Others subjects
are objects and classes, accessing text and SQL databases, graphical
applications, writing secure scripts, and Internet applications
programming.
Annotation c. Book News, Inc., Portland, OR (booknews.com) Synopsis:"Perl Cookbook" is a collection of hundreds of problems and their solutions (with examples) for anyone programming in Perl. The topics range from beginner questions to techniques that are helpful for even the most experienced Perl programmers. Synopsis:This comprehensive collection of problems, solutions, and practical examples for anyone programming in Perl covers everything from beginner questions to techniques for even the most experienced Perl programmer. It contains hundreds of Perl "recipes" that were rigorously reviewed by scores of the best minds inside and outside of Perl, foremost of which was Larry Wall, the creator of Perl himself. You'll find recipes for manipulating strings, numbers, dates, arrays, and hashes; pattern matching and text substitutions; references, data structures, objects, and classes; signals and exceptions; accessing text, hashes, and SQL databases; and managing other processes. You'll also uncover recipes for writing secure scripts; client-server programming; Internet applications programming with mail, news, ftp, and telnet; and CGI programming and Web automation. Description:Includes bibliographical references (p. xxvii-xxix) and index. Table of Contents Table of Contents
Foreword
Preface
1. Strings
1.0. Introduction
1.1. Accessing Substrings
1.2. Establishing a Default Value
1.3. Exchanging Values Without Using Temporary Variables
1.4. Converting Between ASCII Characters and Values
1.5. Processing a String One Character at a Time
1.6. Reversing a String by Word or Character
1.7. Expanding and Compressing Tabs
1.8. Expanding Variables in User Input
1.9. Controlling Case
1.10. Interpolating Functions and Expressions Within Strings
1.11. Indenting Here Documents
1.12. Reformatting Paragraphs
1.13. Escaping Characters
1.14. Trimming Blanks from the Ends of a String
1.15. Parsing Comma-Separated Data
1.16. Soundex Matching
1.17. Program: fixstyle
1.18. Program: psgrep
2. Numbers
2.0. Introduction
2.1. Checking Whether a String Is a Valid Number
2.2. Comparing Floating-Point Numbers
2.3. Rounding Floating-Point Numbers
2.4. Converting Between Binary and Decimal
2.5. Operating on a Series of Integers
2.6. Working with Roman Numerals
2.7. Generating Random Numbers
2.8. Generating Different Random Numbers
2.9. Making Numbers Even More Random
2.10. Generating Biased Random Numbers
2.11. Doing Trigonometry in Degrees, not Radians
2.12. Calculating More Trigonometric Functions
2.13. Taking Logarithms
2.14. Multiplying Matrices
2.15. Using Complex Numbers
2.16. Converting Between Octal and Hexadecimal
2.17. Putting Commas in Numbers
2.18. Printing Correct Plurals
2.19. Program: Calculating Prime Factors
3. Dates and Times
3.0. Introduction
3.1. Finding Today's Date
3.2. Converting DMYHMS to Epoch Seconds
3.3. Converting Epoch Seconds to DMYHMS
3.4. Adding to or Subtracting from a Date
3.5. Difference of Two Dates
3.6. Day in a Week/Month/Year or Week Number
3.7. Parsing Dates and Times from Strings
3.8. Printing a Date
3.9. High-Resolution Timers
3.10. Short Sleeps
3.11. Program: hopdelta
4. Arrays
4.0. Introduction
4.1. Specifying a List In Your Program
4.2. Printing a List with Commas
4.3. Changing Array Size
4.4. Doing Something with Every Element in a List
4.5. Iterating Over an Array by Reference
4.6. Extracting Unique Elements from a List
4.7. Finding Elements in One Array but Not Another
4.8. Computing Union, Intersection, or Difference of Unique Lists
4.9. Appending One Array to Another
4.10. Reversing an Array
4.11. Processing Multiple Elements of an Array
4.12. Finding the First List Element That Passes a Test
4.13. Finding All Elements in an Array Matching Certain Criteria
4.14. Sorting an Array Numerically
4.15. Sorting a List by Computable Field
4.16. Implementing a Circular List
4.17. Randomizing an Array
4.18. Program: words
4.19. Program: permute
5. Hashes
5.0. Introduction
5.1. Adding an Element to a Hash
5.2. Testing for the Presence of a Key in a Hash
5.3. Deleting from a Hash
5.4. Traversing a Hash
5.5. Printing a Hash
5.6. Retrieving from a Hash in Insertion Order
5.7. Hashes with Multiple Values Per Key
5.8. Inverting a Hash
5.9. Sorting a Hash
5.10. Merging Hashes
5.11. Finding Common or Different Keys in Two Hashes
5.12. Hashing References
5.13. Presizing a Hash
5.14. Finding the Most Common Anything
5.15. Representing Relationships Between Data
5.16. Program: dutree
6. Pattern Matching
6.0. Introduction
6.1. Copying and Substituting Simultaneously
6.2. Matching Letters
6.3. Matching Words
6.4. Commenting Regular Expressions
6.5. Finding the Nth Occurrence of a Match
6.6. Matching Multiple Lines
6.7. Reading Records with a Pattern Separator
6.8. Extracting a Range of Lines
6.9. Matching Shell Globs as Regular Expressions
6.10. Speeding Up Interpolated Matches
6.11. Testing for a Valid Pattern
6.12. Honoring Locale Settings in Regular Expressions
6.13. Approximate Matching
6.14. Matching from Where the Last Pattern Left Off
6.15. Greedy and Non-Greedy Matches
6.16. Detecting Duplicate Words
6.17. Expressing AND, OR, and NOT in a Single Pattern
6.18. Matching Multiple-Byte Characters
6.19. Matching a Valid Mail Address
6.20. Matching Abbreviations
6.21. Program: urlify
6.22. Program: tcgrep
6.23. Regular Expression Grabbag
7. File Access
7.0. Introduction
7.1. Opening a File
7.2. Opening Files with Unusual Filenames
7.3. Expanding Tildes in Filenames
7.4. Making Perl Report Filenames in Errors
7.5. Creating Temporary Files
7.6. Storing Files Inside Your Program Text
7.7. Writing a Filter
7.8. Modifying a File in Place with Temporary File
7.9. Modifying a File in Place with -i Switch
7.10. Modifying a File in Place Without a Temporary File
7.11. Locking a File
7.12. Flushing Output
7.13. Reading from Many Filehandles Without Blocking
7.14. Doing Non-Blocking I/O
7.15. Bytes to Read
7.16. Storing Filehandles in Variables
7.17. Caching Open Output Filehandles
7.18. Printing to Many Filehandles Simultaneously
7.19. Opening and Closing File Descriptors by Number
7.20. Copying Filehandles
7.21. Program: netlock
7.22. Program: lockarea
8. File Contents
8.0. Introduction
8.1. Reading Lines with Continuation Characters
8.2. Counting Lines (or Paragraphs or Records) in a File
8.3. Processing Every Word in a File
8.4. Reading a File Backwards by Line or Paragraph
8.5. Trailing a Growing File
8.6. Picking a Random Line from a File
8.7. Randomizing All Lines
8.8. Reading a Particular Line in a File
8.9. Processing Variable-Length Text Fields
8.10. Removing the Last Line of a File
8.11. Processing Binary Files
8.12. Using Random-Access I/O
8.13. Updating a Random-Access File
8.14. Reading a String from a Binary File
8.15. Reading Fixed-Length Records
8.16. Reading Configuration Files
8.17. Testing a File for Trustworthiness
8.18. Program: tailwtmp
8.19. Program: tctee
8.20. Program: laston
9. Directories
9.0. Introduction
9.1. Getting and Setting Timestamps
9.2. Deleting a File
9.3. Copying or Moving a File
9.4. Recognizing Two Names for the Same File
9.5. Processing All Files in a Directory
9.6. Globbing, or Getting a List of Filenames Matching a Pattern
9.7. Processing All Files in a Directory Recursively
9.8. Removing a Directory and Its Contents
9.9. Renaming Files
9.10. Splitting a Filename into Its Component Parts
9.11. Program: symlink
9.12. Program: lst
10. Subroutines
10.0. Introduction
10.1. Accessing Subroutine Arguments
10.2. Making Variables Private to a Function
10.3. Creating Persistent Private Variables
10.4. Determining Current Function Name
10.5. Passing Arrays and Hashes by Reference
10.6. Detecting Return Context
10.7. Passing by Named Parameter
10.8. Skipping Selected Return Values
10.9. Returning More Than One Array or Hash
10.10. Returning Failure
10.11. Prototyping Functions
10.12. Handling Exceptions
10.13. Saving Global Values
10.14. Redifining a Function
10.15. Trapping Undefined Function Calls with AUTOLOAD
10.16. Nesting Subroutines
10.17. Program: Sorting Your Mail
11. References and Records
11.0. Introduction
11.1. Taking References to Arrays
11.2. Making Hashes of Arrays
11.3. Taking References to Hashes
11.4. Taking References to Functions
11.5. Taking References to Scalars
11.6. Creating Arrays of Scalar References
11.7. Using Closures Instead of Objects
11.8. Creating References to Methods
11.9. Constructing Records
11.10. Reading and Writing Hash Records to Text Files
11.11. Printing Data Structures
11.12. Copying Data Structures
11.13. Storing Data Structures to Disk
11.14. Transparently Persistent Data Structures
11.15. Program: Binary Trees
12. Packages, Libraries, and Modules
12.0. Introduction
12.1. Defining a Module's Interface
12.2. Trapping Errors in require or use
12.3. Delaying use Until Run Time
12.4. Making Variables Private to a Module
12.5. Determining the Caller's Package
12.6. Automating Module Clean-Up
12.7. Keeping Your Own Module Directory
12.8. Preparing a Module for Distribution
12.9. Speeding Module Loading with SelfLoader
12.10. Speeding Up Module Loading with Autoloader
12.11. Overriding Built-In Functions
12.12. Reporting Errors and Warnings Like Built-Ins
12.13. Referring to Packages Indirectly
12.14. Using h2ph to Translate C #include Files
12.15. Using h2xs to Make a Module with C Code
12.16. Documenting Your Module with Pod
12.17. Building and Installing a CPAN Module
12.18. Example: Module Template
12.19. Program: Finding Versions and Descriptions of Installed Modules
13. Classes, Objects, and Ties
13.0. Introduction
13.1. Constructing an Object
13.2. Destroying an Object
13.3. Managing Instance Data
13.4. Managing Class Data
13.5. Using Classes as Structs
13.6. Cloning Objects
13.7. Calling Methods Indirectly
13.8. Determining Subclass Membership
13.9. Writing an Inheritable Class
13.10. Accessing Overridden Methods
13.11. Generating Attribute Methods Using AUTOLOAD
13.12. Solving the Data Inheritance Problem
13.13. Coping with Circular Data Structures
13.14. Overloading Operators
13.15. Creating Magic Variables with tie
14. Database Access
14.0. Introduction
14.1. Making and Using a DBM File
14.2. Emptying a DBM File
14.3. Converting Between DBM Files
14.4. Merging DBM Files
14.5. Locking DBM Files
14.6. Sorting Large DBM Files
14.7. Treating a Text File as a Database Array
14.8. Storing Complex Data in a DBM File
14.9. Persistent Data
14.10. Executing an SQL Command Using DBI and DBD
14.11. Program: ggh-Grep Netscape Global History
15. User Interfaces
15.0. Introduction
15.1. Parsing Program Arguments
15.2. Testing Whether a Program Is Running Interactively
15.3. Clearing the Screen
15.4. Determining Terminal or Window Size
15.5. Changing Text Color
15.6. Reading from the Keyboard
15.7. Ringing the Terminal Bell
15.8. Using POSIX termios
15.9. Checking for Waiting Input
15.10. Reading Passwords
15.11. Editing Input
15.12. Managing the Screen
15.13. Controlling Another Program with Expect
15.14. Creating Menus with Tk
15.15. Creating Dialog Boxes with Tk
15.16. Responding to Tk Resize Events
15.17. Removing the DOS Shell Window with Windows Perl/Tk
15.18. Program: Small termcap program
15.19. Program: tkshufflepod
16. Process Management and Communication
16.0. Introduction
16.1. Gathering Output from a Program
16.2. Running Another Program
16.3. Replacing the Current Program with a Different One
16.4. Reading or Writing to Another Program
16.5. Filtering Your Own Output
16.6. Preprocessing Input
16.7. Reading STDERR from a Program
16.8. Controlling Input and Output of Another Program
16.9. Controlling the Input, Output, and Error of Another Program
16.10. Communicating Between Related Processes
16.11. Making a Process Look Like a File with Named Pipes
16.12. Sharing Variables in Different Processes
16.13. Listing Available Signals
16.14. Sending a Signal
16.15. Installing a Signal Handler
16.16. Temporarily Overriding a Signal Handler
16.17. Writing a Signal Handler
16.18. Catching Ctrl-C
16.19. Avoiding Zombie Processes
16.20. Blocking Signals
16.21. Timing Out an Operation
16.22. Program: sigrand
17. Sockets
17.0. Introduction
17.1. Writing a TCP Client
17.2. Writing a TCP Server
17.3. Communicating over TCP
17.4. Setting Up a UDP Client
17.5. Setting Up a UDP Server
17.6. Using UNIX Domain Sockets
17.7. Identifying the Other End of a Socket
17.8. Finding Your Own Name and Address
17.9. Closing a Socket After Forking
17.10. Writing Bidirectional Clients
17.11. Forking Servers
17.12. Pre-Forking Servers
17.13. Non-Forking Servers
17.14. Writing a Multi-Homed Server
17.15. Making a Daemon Server
17.16. Restarting a Server on Demand
17.17. Program: backsniff
17.18. Program: fwdport
18. Internet Services
18.0. Introduction
18.1. Simple DNS Lookups
18.2. Being an FTP Client
18.3. Sending Mail
18.4. Reading and Posting Usenet News Messages
18.5. Reading Mail with POP3
18.6. Simulating Telnet from a Program
18.7. Pinging a Machine
18.8. Using Whois to Retrieve Information from the InterNIC
18.9. Program: expn and vrfy
19. CGI Programming
19.0. Introduction
19.1. Writing a CGI Script
19.2. Redirecting Error Messages
19.3. Fixing a 500 Server Error
19.4. Writing a Safe CGI Program
19.5. Making CGI Scripts Efficient
19.6. Executing Commands Without Shell Escapes
19.7. Formatting Lists and Tables with HTML Shortcuts
19.8. Redirecting to a Different Location
19.9. Debugging the Raw HTTP Exchange
19.10. Managing Cookies
19.11. Creating Sticky Widgets
19.12. Writing a Multiscreen CGI Script
19.13. Saving a Form to a File or Mail Pipe
19.14. Program: chemiserie
20. Web Automation
20.0. Introduction
20.1. Fetching a URL from a Perl Script
20.2. Automating Form Submission
20.3. Extracting URLs
20.4. Converting ASCII to HTML
20.5. Converting HTML to ASCII
20.6. Extracting or Removing HTML Tags
20.7. Finding Stale Links
20.8. Finding Fresh Links
20.9. Creating HTML Templates
20.10. Mirroring Web Pages
20.11. Creating a Robot
20.12. Parsing a Web Server Log File
20.13. Processing Server Logs
20.14. Program: htmlsub
20.15. Program: hrefsub
Index
What Our Readers Are SayingBe the first to add a comment for a chance to win!Product Details
Other books you might like
| |||
|
| ||||
|
|
||||