Perl Cookbook
Home > Computing and Information Technology > Computer programming / software engineering > Programming and scripting languages: general > Perl Cookbook
Perl Cookbook

Perl Cookbook

|
     0     
5
4
3
2
1




Out of Stock


Notify me when this book is in stock
About the Book

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: Manipulation of strings, numbers, dates, arrays, and hashes Reading, writing, and updating text and binary files Pattern matching and text substitutions Subroutines, libraries, and modules References, data structures, objects, and classes Signals and exceptions Accessing text, hashes, and SQL databases Screen addressing, menus, and graphical applications Managing other processes Writing secure scripts Client-server programming Internet applications programming with mail, news, ftp, and telnet CGI programming and Web automation 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.

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 158 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


Best Sellers


Product Details
  • ISBN-13: 9781565922433
  • Publisher: O'Reilly Media
  • Publisher Imprint: O'Reilly Media
  • Height: 232 mm
  • Returnable: N
  • Width: 178 mm
  • ISBN-10: 1565922433
  • Publisher Date: 08 Sep 1998
  • Binding: Paperback
  • Language: English
  • Weight: 1150 gr


Similar Products

Add Photo
Add Photo

Customer Reviews

REVIEWS      0     
Click Here To Be The First to Review this Product
Perl Cookbook
O'Reilly Media -
Perl Cookbook
Writing guidlines
We want to publish your review, so please:
  • keep your review on the product. Review's that defame author's character will be rejected.
  • Keep your review focused on the product.
  • Avoid writing about customer service. contact us instead if you have issue requiring immediate attention.
  • Refrain from mentioning competitors or the specific price you paid for the product.
  • Do not include any personally identifiable information, such as full names.

Perl Cookbook

Required fields are marked with *

Review Title*
Review
    Add Photo Add up to 6 photos
    Would you recommend this product to a friend?
    Tag this Book Read more
    Does your review contain spoilers?
    What type of reader best describes you?
    I agree to the terms & conditions
    You may receive emails regarding this submission. Any emails will include the ability to opt-out of future communications.

    CUSTOMER RATINGS AND REVIEWS AND QUESTIONS AND ANSWERS TERMS OF USE

    These Terms of Use govern your conduct associated with the Customer Ratings and Reviews and/or Questions and Answers service offered by Bookswagon (the "CRR Service").


    By submitting any content to Bookswagon, you guarantee that:
    • You are the sole author and owner of the intellectual property rights in the content;
    • All "moral rights" that you may have in such content have been voluntarily waived by you;
    • All content that you post is accurate;
    • You are at least 13 years old;
    • Use of the content you supply does not violate these Terms of Use and will not cause injury to any person or entity.
    You further agree that you may not submit any content:
    • That is known by you to be false, inaccurate or misleading;
    • That infringes any third party's copyright, patent, trademark, trade secret or other proprietary rights or rights of publicity or privacy;
    • That violates any law, statute, ordinance or regulation (including, but not limited to, those governing, consumer protection, unfair competition, anti-discrimination or false advertising);
    • That is, or may reasonably be considered to be, defamatory, libelous, hateful, racially or religiously biased or offensive, unlawfully threatening or unlawfully harassing to any individual, partnership or corporation;
    • For which you were compensated or granted any consideration by any unapproved third party;
    • That includes any information that references other websites, addresses, email addresses, contact information or phone numbers;
    • That contains any computer viruses, worms or other potentially damaging computer programs or files.
    You agree to indemnify and hold Bookswagon (and its officers, directors, agents, subsidiaries, joint ventures, employees and third-party service providers, including but not limited to Bazaarvoice, Inc.), harmless from all claims, demands, and damages (actual and consequential) of every kind and nature, known and unknown including reasonable attorneys' fees, arising out of a breach of your representations and warranties set forth above, or your violation of any law or the rights of a third party.


    For any content that you submit, you grant Bookswagon a perpetual, irrevocable, royalty-free, transferable right and license to use, copy, modify, delete in its entirety, adapt, publish, translate, create derivative works from and/or sell, transfer, and/or distribute such content and/or incorporate such content into any form, medium or technology throughout the world without compensation to you. Additionally,  Bookswagon may transfer or share any personal information that you submit with its third-party service providers, including but not limited to Bazaarvoice, Inc. in accordance with  Privacy Policy


    All content that you submit may be used at Bookswagon's sole discretion. Bookswagon reserves the right to change, condense, withhold publication, remove or delete any content on Bookswagon's website that Bookswagon deems, in its sole discretion, to violate the content guidelines or any other provision of these Terms of Use.  Bookswagon does not guarantee that you will have any recourse through Bookswagon to edit or delete any content you have submitted. Ratings and written comments are generally posted within two to four business days. However, Bookswagon reserves the right to remove or to refuse to post any submission to the extent authorized by law. You acknowledge that you, not Bookswagon, are responsible for the contents of your submission. None of the content that you submit shall be subject to any obligation of confidence on the part of Bookswagon, its agents, subsidiaries, affiliates, partners or third party service providers (including but not limited to Bazaarvoice, Inc.)and their respective directors, officers and employees.

    Accept

    New Arrivals

    Inspired by your browsing history


    Your review has been submitted!

    You've already reviewed this product!