I supply very little code that is new. The idea is that, once something has been developed to perform a task, you should make use of it, or you're wasting your precious time.
"Don't reinvent the wheel." Although this advice sounds trite, it's important to the continued development of Perl5 as a viable object-oriented language. The authors of the many useful Perl5 modules have spent a lot of time and effort to provide their modules. Because this voluntary contribution is the foundation of the Perl development effort, it should be nurtured and utilized to the fullest extent. I suggest that you try to utilize these modules and help out where you can, by reporting bugs and providing fixes and enhancements back to the author where appropriate.
Using the new object-oriented features and techniques of Perl5 to develop new programs enhances the potential for reusability of your code. Well-written programs can be adapted to serve multiple purposes, possibly even being promoted to the status of libraries or modules. (You'll learn how to register and/or submit your code as a new module later in this chapter.)
You can use the Perl module with references to achieve an object-oriented look and feel in your programs. You can create inheritance (single and multiple), relationships, virtual classes, constructors, destructors, and implement simple messaging with Perl5.
I cover some of these techniques within the extended portion of this tutorial.
Extensible and Embeddable
The Perl modules provide a reusable interface for many commonly used programming tasks. Many of the modules are also Perl extensions, which means that some component of their interface is actually written using the Perl XSUB language. After the XSUB code is translated to C, it is compiled with a C compiler. The functions in the C code are then accessible as Perl subroutines in your program.
Perl5 is now embeddable, as well. A programmer can create a Perl interpreter in any regular program written in C and, through the use of CallBacks and other internal routines, interface to the Perl interpreter within his or her program. This capability can provide an extremely powerful set of additional features for editors, servers, and other tools.
The details regarding XSUB programming and creation of shared libraries are beyond the scope of this tutorial. In this tutorial, I don't tell you more than what you need to use them in your Perl programs. I assume that they've been built and installed on your machine. Likewise for embedded Perl, I only mention it here as a new feature.