Summary
In this chapter, we explored the insides of modules and packages and how to write our own modules. We saw how packages affect the symbol table and looked at a few ways to take advantage of this knowledge to examine and even manipulate package contents programmatically.
We then looked at Perl’s special phase transition blocks, BEGIN, CHECK, INIT, and END, and how we can use them to create modules that can initialize themselves and carry out various kinds of checks between phases of the interpreter’s operation.
The next main topic discussed was the autoloading mechanism, which allows us to intercept calls to subroutines that do not exist and define them on the fly if we want to. From there we looked at importing and exporting, completing the discussion started in the previous chapter from the viewpoint of the module being imported from. We looked at the basics of the import mechanism, how we can use it to do other things than importing, and how to use the Exporter module to handle many common import and export requirements.
We also looked at package attributes and implementing our own attributes for subroutines and variables with the Attribute::Handlers module. Like the import/export mechanism, this completes the previous discussion started in Chapter 7, where we introduced using Perl’s built-in attributes from the perspective of the implementing module.
Finally, we went through the process of creating an installable module, including the use of h2xs to create the initial working directory and files, bundling the completed module into a distributable archive, and then installing the archive on another platform.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
Rights and permissions
Copyright information
© 2005 Peter Wainwright
About this chapter
Cite this chapter
(2005). Inside Modules and Packages. In: Pro Perl. Apress. https://doi.org/10.1007/978-1-4302-0014-7_10
Download citation
DOI: https://doi.org/10.1007/978-1-4302-0014-7_10
Publisher Name: Apress
Print ISBN: 978-1-59059-438-4
Online ISBN: 978-1-4302-0014-7
eBook Packages: Professional and Applied ComputingProfessional and Applied Computing (R0)Apress Access Books