Extending and Embedding Perl

Tim Jenness and Simon Cozens

2002 | 384 pages | B&W
ISBN: 1930110820

Out of Print $44.95 Softbound print + eBook
$35.99 eBook edition (PDF only)



Extending and Embedding Perl explains how to expand the functionality and usefulness of the Perl programming language and how to use Perl from C programs. It begins simply but also covers complex issues using real code examples from the Perl source. The book discusses how to write interfaces to C libraries (as well as C++ and Fortran libraries). It shows you how to implement Perl callbacks for C libraries, how to pass Perl hashes and arrays between Perl and C, and how to use the Perl Data Language infrastructure to improve the speed of array operations.

Additionally, the book peers under the hood to see how the Perl programming language really works by looking at the interpreter. The make-up of Perl variables is discussed along with details on how a Perl program is parsed and converted to executable code.

What's Inside:


A Perl developer for 7 years, Tim Jenness has ten modules on CPAN including two that are distributed as part of the core Perl distribution (File::Temp and Pod::LateX).

Simon Cozens the author of Beginning Perl, was the release manager for the first four releases of the Perl 6 runtime engine, Parrot.


Two sample chapters of Extending and Embedding Perl are available in PDF format. You need Adobe's free Acrobat Reader software to view it. You may download Acrobat Reader here.

Download Chapter 2
Download Chapter 11


"My expectations were exceeded by this book in every way. This is not just a guide to writing Perl modules with C interspersed. It also provides an in depth look at everything that happens from the second Perl interprets your source file to the second it exits. ...This book fills a gap in the online Perl documentation by making many complex topics easily accessible. A good mix of theory and practice guides the reader through tasks quickly, without leaving them stranded. I recommend this book for any Perl programmers seeking to better harness Perl in their work."
Computing Reviews, August 2003

"...a welcome addition to the arsenal of Perl books. It should help with demystifying XS and associated technologies...an invaluable reference."
—Linux Journal, July 2003

"Extending and Embedding Perl provides an authoritative account of Perl's most advanced features...experienced C and Perl programmers will find this book both engaging and illuminating."
IBM DeveloperWorks

"Extending and Embedding Perl is characterized by profound expertise, attention to detail, literate writing, and excellent editorial and production values. This book is so necessary that it would be a must-have for the problem domain, even were it less finely crafted?a masterpiece that will keep its value for years...an exceptionally useful and readable book."
The Perl Journal, November 2002

"...a deliberate thorough guide led by authors that are both extremely knowledgeable and also capable of communicating that knowledge..."
—Kansas City Perl Mongers

"...aims to take the black magic out of understanding [Perl]...indispensable in gaining a good foothold on using Perl in, from, and around C."

"...a must-have for the problem domain, even were it less finely crafted; we're lucky that the one book to adequately address the most puzzling facets of Perl happens to be a masterpiece that will keep its value for years."
The Perl Journal

"I've not seen a more complete and well written source of information on the subject of embedding...Each chapter has an extensive set of annotated examples and the style of writing makes the learning process easier...The book is great for learning and great for reference, which is a combination other books often fail to achieve."

"Everything related to Perl internals is found here; the Perl internal API, XS, SWIG, embedding Perl in C, and C in Perl. The book is organized well, and is fine as a reference work."
The Perl Review

"This book was indispensable in gaining a good foot-hold on using Perl in, from, and around C. I found it a good reference guide as well as an easy linear read. It is not a replacement for the perlguts, perlapi and perlxs documentation. But then again, it doesn't try to be. The annotated code examples with every line explained make following the book with development of your own solution a lot easier than in some other books."

"This book is well written, concise, and an absolute must for all those, such as myself, who need to work with C and Perl, but who've been putting off the ... day. With this superb book, we cowards no longer have any excuses. Magic! :-)"
—Andrew Duncan, Amazon Reader


Source code for Extending and Embedding Perl is available as a single tar.gz file.

Download the source: Source Code (tar.gz) (2.5 Mb)