What is a Module
|
- package gives the name of the module
- The filename would be Sample/Module.pm and the Sample directory will live in one of the directories listed in @INC
- The Exporter module makes the changes to symbol tables to export functions and variables from one package to another
- These are package variables needed to make Exporter happy
- $VERSION is also known as $Sample::Module::VERSION
- Required variable
- Should be a real number like 0.1 or 2.9996
- Should not be like LINUX kernal numbering 2.2.4 with extra periods
- Modules to inherit variables, methods, and functions from
|
- Functions and Variables here are exported only if requested.
- Otherwise they can still be used, but you must give the full name like $Sample::Module::Foo
- my variables can not be exported, must use vars
|
|
- All modules (and required files) need to return a true value. The simplest way to guarantee a true value is to end the module with a "1;", which is true.
The "__END__" tells Perl to ignore anything after it. If you have documentation or retired functions you can't yet throw away, it is easy to leave them after the "__END__" where they will do no harm.
No comments:
Post a Comment