Authors: Tom Christiansen and Nathan Torkington
Publisher: O'Reilly & Associates
Price: $39.95 US
Reviewer: James Lee
Having written programs in Perl for a number of years, I fondly remember spending many hours leafing through the first edition of O'Reilly's Programming Perl (also known as “the Camel Book”), an excellent book covering the Perl programming language up to version 4.0.36. That book was well-written, technically correct and very witty. Two chapters of the first edition of Programming Perl I was particularly fond of, “Common Tasks with Perl” and “Real Perl Programs” contained numerous common tasks and real programs using Perl.
In 1996, O'Reilly published the second edition of Programming Perl, an excellent book covering all features of Perl including those features new to Perl version 5. The size of the book expanded from 465 pages in the first edition to a whopping 645 pages in the second. Many topics new to Perl 5 were added to the second edition, including a discussion of references and object-oriented programming. However, due to its size, portions of the first edition could not be covered in the second. Therefore, parts of the first edition were deleted, including my favorite “Common Tasks with Perl” and “Real Perl Programs” chapters.
Perl Cookbook (also known as “the Ram Book”) is a companion to Programming Perl, expanding the chapters of real Perl programs in the first edition of the Camel book to a massive 757 pages of thoroughly explained, useful Perl code. In this book, Tom Christiansen and Nathan Torkington cover many topics providing numerous code examples known as recipes (it is a “cookbook”, after all). The introduction claims it is not a tutorial nor a reference, but rather states “this is a book for learning more Perl”. And so it is.
This is a book for all types of Perl programmers from beginner to expert. If you are looking for a book with hundreds of examples to cut and paste, or something that explains in detail how to do many different things using Perl, this book is for you.
The book starts with recipes to handle Perl's basic data types. Each of the following five topics gets its own chapter: strings, numbers, dates and times, arrays and hashes.
Chapter 6 discusses pattern matching and goes into great detail on using Perl's regular expressions.
Chapters 7, 8 and 9 deal with file access, file contents and directories. Chapter 10 discusses subroutines (check out the nifty programs to sort e-mail at the end of this chapter).
Chapters 11, 12 and 13 discuss references, packages, libraries, modules, classes, object and ties. These topics are traditionally difficult to master with Perl, yet I found these chapters to be well-written and understandable. I was particularly impressed with the section on using tie at the end of Chapter 13.
Chapter 14 covers database access, including UNIX DBM databases and the DBI module. Chapter 15 discusses user interfaces from the terminal, the Tk interface and the Expect programming language.
The remaining five chapters discuss networking with Perl. Topics include process management and communication, sockets, Internet services, CGI programming and web automation.
I have found this book to be extremely helpful, technically excellent and loaded with useful and usable source code. For example, I recently wrote a CGI program that accepts a floating-point number from the user, and I wanted to use a regular expression to verify that the number entered was valid. I thought to myself, “Hmm, I can either create the regular expression myself, or see if this issue is covered in the Perl Cookbook.” Noting that “Laziness” is one of the three primary virtues of a Perl programmer, I decided to look in the book. In the table of contents, I immediately found a recipe titled “Checking Whether a String Is a Valid Number”. Sensing I was on to something, I turned to page 44 and found the following regular expression to verify correct C-style floating point numbers:
I suppose that, with a bit of time and a lot of testing, I could have come up with a working regular expression. But I didn't need to—the answer was found in the Perl Cookbook.
The Perl Cookbook has the answers to many common Perl questions. Need to find all unique entries in a list? Try page 102. Want to create a hash, but retrieve the key/value pairs from the hash in the order entered? Turn to page 139. Want to POP your e-mail from your server? See page 656.
I especially liked Chapter 20, entitled “Web Automation”. Did you know it takes only five lines of Perl code to submit a form to a CGI program using the GET method? This example is from page 710:
use LWP::Simple; use URI::URL; my $url = url('http://www.perl.com/cgi-bin/cpan_mod'); $url->query_form(module => 'DB_File', readme => 1); $content = get($url);
Mirroring a web page takes only two lines of code (from page 724):
use LWP::Simple; mirror($URL, $local_filename);Code like this makes Perl the world's most useful programming language. Examples like these make the Perl Cookbook the most useful Perl book I own.
The book contains a mountain of source code, all of which is available from the O'Reilly FTP site (ftp://ftp.oreilly.com/published/oreilly/perl/cookbook/). There, you can find over 130 full-length programs as well as all of the code snippets from the book.
Since this is a cookbook covering a number of topics, readers looking for in-depth discussions of the topics mentioned above should be aware of the fact that they are not covered in minute detail. For instance, the chapter on CGI programming is a brief description that will be excellent if you have some knowledge of CGI, but if you are looking for in-depth discussion, you should check out a CGI book. This makes sense—cookbooks are not tutorials. They present recipes, with the assumption that you know the basics.
In summary, if you are a Perl programmer, this book is essential. If you are new to Perl and want to become a Perl programmer, this book is highly recommended as a tool to learn more Perl. If you are wondering what Perl is all about and what Perl can do for you, this book deserves a look. If you haven't heard of Perl, where have you been?
Practical Task Scheduling Deployment
July 20, 2016 12:00 pm CDT
One of the best things about the UNIX environment (aside from being stable and efficient) is the vast array of software tools available to help you do your job. Traditionally, a UNIX tool does only one thing, but does that one thing very well. For example, grep is very easy to use and can search vast amounts of data quickly. The find tool can find a particular file or files based on all kinds of criteria. It's pretty easy to string these tools together to build even more powerful tools, such as a tool that finds all of the .log files in the /home directory and searches each one for a particular entry. This erector-set mentality allows UNIX system administrators to seem to always have the right tool for the job.
Cron traditionally has been considered another such a tool for job scheduling, but is it enough? This webinar considers that very question. The first part builds on a previous Geek Guide, Beyond Cron, and briefly describes how to know when it might be time to consider upgrading your job scheduling infrastructure. The second part presents an actual planning and implementation framework.
Join Linux Journal's Mike Diehl and Pat Cameron of Help Systems.
Free to Linux Journal readers.Register Now!
- Murat Yener and Onur Dundar's Expert Android Studio (Wrox)
- SUSE LLC's SUSE Manager
- My +1 Sword of Productivity
- Non-Linux FOSS: Caffeine!
- Tech Tip: Really Simple HTTP Server with Python
- Managing Linux Using Puppet
- Google's SwiftShader Released
- Parsing an RSS News Feed with a Bash Script
- SuperTuxKart 0.9.2 Released
- Doing for User Space What We Did for Kernel Space
With all the industry talk about the benefits of Linux on Power and all the performance advantages offered by its open architecture, you may be considering a move in that direction. If you are thinking about analytics, big data and cloud computing, you would be right to evaluate Power. The idea of using commodity x86 hardware and replacing it every three years is an outdated cost model. It doesn’t consider the total cost of ownership, and it doesn’t consider the advantage of real processing power, high-availability and multithreading like a demon.
This ebook takes a look at some of the practical applications of the Linux on Power platform and ways you might bring all the performance power of this open architecture to bear for your organization. There are no smoke and mirrors here—just hard, cold, empirical evidence provided by independent sources. I also consider some innovative ways Linux on Power will be used in the future.Get the Guide