Perl Black Book
Steven Holzner · Medical Entomology and Zoology · 1999
From the Book: Welcome to the big book of Perl. This book is designed to be as comprehensive, and easily accessible, as is possible for one book on Perl to be. In fact, this book is written to have as much coverage as any two of its competitors-and adds hundreds of pages of CGI Internet script programming to boot. Perl is no ordinary programming language: It inspires devotion, passion, exaltation and eccentricity-not to mention exasperation and frustration. It's more than a programming language; it's a cause, the stuff of programmer poets and fanatics. Perl may be complex and arcane at times, it may even be confusing and inconsistent, but to a true devotee, there's no other way to go. You'll see what I mean as you read this book. In its 12-year reign, the Practical Extraction and Reporting Language (also called, often by the same people, the Pathologically Eclectic Rubbish Lister) has become the object of much affection. Remarkable numbers of people devote incredible numbers of volunteer hours to using, improving, and disseminating it. I started working with Perl years before I thought of writing a book on it. Maybe the Perl way of doing things will turn you into a fanatic, too. It's really hard not to get exhilarated by the amazing amount of power you have when using Perl-everything from object-oriented programming to Internet socket programming, from writing Internet shopping cart programs to creating Web servers. We'll do all those things here. What's In This Book This book is designed to give you as much of the whole Perl story as one book can hold. We'll see not only the full Perl syntax-from creating simple scalars to complex data structures,from object-oriented programming to extending Perl using C-but also every major programming area in which Perl is used today. Hundreds of real-world topics are covered in this book, such as connecting Perl to databases, to Windows OLE automation servers, to other processes, and so on; they're all here. We'll cover file handling, socket programming that lets your programs communicate across the Internet, powerful text processor applications, object-oriented programming, named pipes, interprocess communication, data encryption, signal handling, module creation, debugging, Perl references, function templates, signal handling, and many more topics. And, each of these topics will come with examples showing just how they work. Another popular topic is the connection between Perl and Tcl/Tk, which lets you display windows, buttons, menus, and more using Perl, so that's another topic in this book. We'll see everything from displaying Tk buttons, scrolling lists, and checkbuttons to letting the user handle involved cascading menus with radio buttons and submenus. Probably the biggest source of Perl's popularity today is the Internet, so we're going to see a tremendous amount of Internet programming in this book-handling the FTP and HTTP protocols, Telnet, email-even downloading posts from Usenet newsgroups. We'll see how to download and upload Web pages, extract links from those pages, submit HTML forms to CGI scripts without using Web browsers, enable online user registration, write an HTTP user agent (that is, a Web browser), and even write a functioning Web server. The real fuel behind Perl's popularity today is Common Gateway Interface (CGI) programming-those Internet scripts that make your Web pages come alive, allowing you to write programs that themselves write Web pages. This book contains a lot of CGI programming-in fact, more than in any one CGI book that I'm aware of. I'll cover how to create and use nearly all the HTML controls in Web pages-text fields, text areas, checkboxes, scrolling lists, radio buttons, password fields, pop-up menus, hidden data fields, Submit and Reset buttons, and more. We'll see how to create image maps and frames, upload files, debug CGI scripts, ensure CGI security, and determine what kinds of image files you can send to a specific browser. We'll create image-based Web page hit counters, a guest book, CGI scripts that can send email, a multiuser chat application, Internet games, and cookies. We'll also implement Web site searches, create CGI shopping carts, and more. The CGI scripts in this book can redirect browsers; handle Web-based databases; handle client pull, server push, and server-side includes; return images; and more. In this book, you'll also see many additions to Perl 5, such as ways to write more readable Perl code, BEGIN and END blocks in packages, POSIX compliance, object-oriented programming, arbitrarily nested data structures, lexical scoping, enhanced use of modules, and other topics. Version 5 presented a big change for Perl, so it's the version this book was written for.