So you've learned Perl, but you're getting frustrated. Perhaps you've taken on a larger project than the ones you're used to. Or you want to add a user interface or a networking component. Or you need to do more complicated error trapping.Whether your knowledge of Perl is casual or deep, this book will make you a more accomplished programmer. Here you can learn the complex techniques for production-ready Perl programs. This book explains methods for manipulating data and objects that may have looked like magic before. Furthermore, it sets Perl in the context of a larger environment, giving you the background you need for dealing with networks, databases, and GUIs. The discussion of internals helps you program more efficiently and embed Perl within C or C within Perl.Major topics covered include:

Practical use of packages and classes (object-oriented programming)

Complex data structures

Persistence (e.g., using a database)

Networking

Graphical interfaces, using the Tk toolkit

Interaction with C language functions

Embedding and extending the Perl interpreter

In addition, the book patiently explains all sorts of language details you've always wanted to know more about, such as the use of references, trapping errors through the eval operator, non-blocking I/O, when closures are helpful, and using ties to trigger actions when data is accessed. You will emerge from this book a better hacker, and a proud master of Perl.

Filehandles, Formats

Colophon

Sriram Srinivasan

Sriram Srinivasan ("Ram") is an expert on distributed object technologies, and develops Java middleware at WebLogic, San Francisco, for fun and profit. He actively pursues his interests in programming languages, databases, transaction processing, networking, and meaningful user interfaces. Sriram has been an enthusiastic user and teacher of Perl for the last six years, and currently teaches a course on advanced Perl programming for the extension program at the University of California at Berkeley. In his spare time, he dabbles in Indian classical music, charcoal drawing, cooking, and biking, and dreams of the day when he can say, "In his spare time, he dabbles in programming languages, ...".

Our look is the result of reader comments, our own experimentation, and feedback from distribution channels. Distinctive covers complement our distinctive approach to technical topics, breathing personality and life into potentially dry subjects. The animal featured on the cover of Advanced Perl Programming is a black leopard. Most leopards are easily recognized by the rosette patterned spots on their coat. Black leopards, often called "black panthers," also have these spots, but they are difficult to see because of the darkness of the fur. Black leopards are born into the same litters as the more common yellowish leopards. They occur most frequently in the wet, forested areas of India and southeast Asia, where the dark color aids in camouflage and hunting.Leopards are among the most widely distributed wild cats. Their range extends throughout most of Africa and India and into much of Asia, the Middle East, and the East Indies. Highly adaptable, leopards are able to hunt almost any animal, and can live in both very wet and arid conditions. Because they almost always share their range with bigger cats, such as lions or tigers, leopards are very cautious. After catching its prey, the leopard will carry it high up into a tree to devour it. The incredible strength of the leopard enables it to climb while carrying animals up to three times its own body weight. Edie Freedman designed the cover of this book, using a 19th-century engraving from the Dover Pictorial Archive. The cover layout was produced with Quark XPress 3.3 using the ITC Garamond font. Whenever possible, our books use RepKover, a durable and flexible lay-flat binding. If the page count exceeds RepKover's limit, perfect binding is used.The inside layout was designed by Nancy Priest and implemented in FrameMaker 5.0 by Mike Sierra. The text and heading fonts are ITC Garamond Light and Garamond Book. The illustrations that appear in the book were created in Macromedia Freehand 5.0 by Robert Romano. This colophon was written by Clairemarie Fisher O'Leary.

It takes the time and effort to de-mistify many troublesome spots. It integrates details from different scripting and system languages to give a very well rounded overview of state of the art. It covers

At first - its very good readeble and clear! It gives you necessary background for dealing with networks, databases, and GUIs, which is important for me. But if you are not much perl experienced than its not for you:-(

I would have to agree that the lack of functional examples does cloud the quality of this book. The text is good, but not having functional examples leaves the complication of whether we should do what the text say or what the example does.

Now I am the first to admit that errors occur. That is what code downloads and errata are supposed to fix. Not only does the code download from www.oreily.com not fix some problems, but does not even include all of the examples present in the book.

As a learning book where you are going to read all the details, the book is good. As a "quck grab it" reference this book fails because of the errors.

Watch out for the Networking: Implementing RPC chapter! There are myriad errors in the code examples. Why doesn't someone review the code, and perhaps actually try to run it?

For example:

The peer demonstration (between two RPC servers) just won't work. Besides the fact that the code has a typo (new_rpc_server instead of new_server, mentioned in the errata), they each create a listening socket, supposedly to each opposite machine. That *won't* work. Even if they created a listening socket on their respective hosts, they wouldn't know who to contact for the TCP connection. The lower-level Msg library doesn't facilitate a server sending messages to some arbitrary client (as the RPC example implies).

Someone should *really* sit and go through the code.

Want another more explicit example:

BEGIN EXCERPT

sub rpc {

my $conn = shift;

my $subname = shift;

$subname = (caller() . '::' . $subname) unless $subname =~ /:/;

my $gimme = wantarray ? 'a' : 's'; # Array or scalar

my $msg_id = ++$g_msg_id;

my $serialized_msg = freeze ('>', $msg_id, $gimme, @_);

END EXCERPT

Notice that he shifts subname off the param list? Then proceeds to build the $serialized_msg with only the @_ params (NOT INCLUDING THE SUBNAME).

This is quite disasterous when the recevier gets here:

BEGIN EXCERPT

my $instant = thaw($msg);

my ($dir, $id, @args) = @$instant;

my ($result, @results);

if ($dir eq '>') {

# New request message

my $gimme = shift @args;

my $sub_name = shift @args;

try {

no strict 'refs'; # Because we call the subroutine using

# a symbolic reference

if ($gimme eq 'a') { # Want an array back

@results = &{$sub_name} (@args);

} else {

$result = &{$sub_name} (@args);

}

END EXCERPT

Notice again that he tries to shift the subname off the thaw'd @args array... Won't work, will it?!

I knew this already but for your knowledge - Don't trust ANYONE else's code. You'll pay for it with a significant loss of time.