next up previous contents
Next: The BEGIN Block Up: Perl Modules Previous: Perl Modules

Module Constructors and Destructors

You may recall constructors and destructors from the discussion about objects in the last chapter. Constructors are used to initialize something and destructors are used to write log messages, close files, and do other clean-up type duties.

Perl has constructors and destructors that work at the module level as well as the class level. The module constructor is called the BEGIN block, while the module destructor is called the END block.