home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam    

Book HomeJava and XSLTSearch this book

Chapter 1. Introduction to Perl

Computer languages differ not so much in what they make possible, but in what they make easy. Perl is designed to make the easy jobs easy, without making the hard jobs impossible. Perl makes it easy to manipulate numbers, text, files, directories, computers, networks, and programs. It also makes it easy to develop, modify, and debug your own programs portably, on any modern operating system.

Perl is especially popular with systems programmers and web developers, but it also appeals to a much broader audience. Originally designed for text processing, it has grown into a sophisticated, general-purpose programming language with a rich software development environment complete with debuggers, profilers, cross-referencers, compilers, interpreters, libraries, syntax-directed editors, and all the rest of the trappings of a "real" programming language.

There are many reasons for Perl's success. For starters, Perl is freely available and freely redistributable. But that's not enough to explain the Perl phenomenon, since many other freeware packages fail to thrive. Perl is not just free; it's also fun. People feel like they can be creative in Perl, because they have freedom of expression.

Perl is both a very simple language and a very rich language. It's a simple language in that the types and structures are simple to use and understand, and it borrows heavily from other languages you may already be familiar with. You don't have to know everything there is to know about Perl before you can write useful programs.

However, Perl is also a rich language, and there is much to learn about it. That's the price of making hard things possible. Although it will take some time for you to absorb all that Perl can do, somewhere down the line you will be glad that you have access to the extensive capabilities of Perl.

1.1. What's Perl Good For?

Perl has the advantage of being easy to learn if you just want to write simple scripts—thus its appeal to the ever-impatient system administrator and the deadline-driven CGI developer. However, as you become more ambitious, Perl lets you act on those ambitions. Chapter 2, "Installing Perl" covers how to get and install Perl, and Chapter 3, "The Perl Executable" through Chapter 6, "Debugging" cover the basics of the Perl language, its functions, and how to use the Perl debugger.

On top of the Perl language itself, however, are the Perl modules. You can think of modules as add-ons to the Perl language that allow you to streamline tasks by providing a consistent API. Perl itself is fun to use, but the modules lend Perl even more flexibility and enormous power. Furthermore, anyone can write and distribute a Perl module. Some modules are deemed important enough or popular enough to be distributed with Perl itself, but very few are actually written by the core Perl developers themselves. Chapter 7, "Packages, Modules, and Objects" introduces you to Perl modules, and Chapter 8, "Standard Modules" covers the standard modules that are distributed with Perl itself.

The most popular Perl module is CGI.pm, which gives a simple interface to developing common gateway interface (CGI) applications in Perl. While Perl itself is indispensable for many different tasks, its text-manipulation features make it perfect for CGI development on the Web. In fact, the resurgence of Perl over the past few years must be credited to its popularity as a CGI language. Chapter 10, "The CGI.pm Module" and Chapter 11, "Web Server Programmingwith mod_perl" talk about using Perl for CGI, including mod_perl, which merges Perl into the Apache web server.

Database interconnectivity is one of the most important functions of any programming language today, and Perl is no exception. DBI is a suite of modules that provide a consistent database-independent interface for Perl. Chapter 12, "Databases and Perl" covers both DBI and DBM (the more primitive but surprisingly effective database interface built directly into Perl).

The eXtensible Markup Language (XML) is quickly becoming the de facto way to store electronic information of any kind. Chapter 13, "XML and Perl" covers the modules designed for Perl and XML processing, and Chapter 14, "SOAP" covers using Perl for managing web services with the XML-based protocol SOAP.

The Internet doesn't start and stop at CGI. Network programming is another of Perl's strengths, with a robust sockets interface and several modules for writing clients and servers for all sorts of Internet services—not only the Web, but also email, news, FTP, LDAP, etc. Chapter 15, "Sockets" through Chapter 19, "Lightweight Directory Access with Net::LDAP" cover the modules for developing fully functional Internet applications in Perl.

The World Wide Web, of course, is the "killer app" of the Internet. LWP is a library of modules devoted to web programming. Chapter 20, "The LWP Library" covers the LWP library.

Perl programs are traditionally command line-based, but the Perl/Tk extension can provide Perl programs with graphical user interfaces, for both Unix and Microsoft Windows. Chapter 21, "Perl/Tk" gives a complete reference to Perl/Tk.

Finally, although Perl is primarily developed for Unix, recent releases of Perl for Windows 95 and Windows NT are gaining popularity, both for CGI and system administration tasks. Chapter 21, "Perl/Tk" through Chapter 24, "ODBC Extension for Win32" cover the Win32 modules for Perl.

As you may have noticed, Section 1.1, "What's Perl Good For?" has sneakily become a description of the contents of this book. This book aims at being a general-purpose reference to all things Perl.

Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.