head 1.4; access; symbols; locks; strict; comment @# @; 1.4 date 2012.10.11.23.56.34; author mjd; state Exp; branches; next 1.3; 1.3 date 99.06.16.14.07.57; author mjd; state Exp; branches; next 1.2; 1.2 date 99.06.08.18.49.52; author mjd; state Exp; branches; next 1.1; 1.1 date 99.06.08.03.54.26; author mjd; state Exp; branches; next ; desc @@ 1.4 log @Add links to archive files; fix link to perl.plover.com @ text @
There are two styles you can use for Perl modules. Both are useful under different circumstances.
In the `exporting' style, the `module file' defines some functions which you can load into your program and use as if you had defined them yourself.
In the `object oriented' style, your module defines a `class' that knows how to construct `objects' that perform actions on behalf of the program when their methods are invoked.
You should visit the Module directory first. It has an extremely simple module, an example program that uses it, and a list of exercises. You should do all the exercises. When you are done you will know how to write a module in the `module' style. The examples are complete, but they are so simple that they will both fit on the screen at the same time. Together they are eighteen lines long.
Then you should move to the Class directory, which has an extremely simple object-oriented module, a sample program, and a list of exercises. Do the exercsises. When you're done you will know how to write a module in the `object oriented' style. The example is a complete object-oriented program that creates an object and calls a method on it. It is a little longer than the other example. It is thirty-nine lines long. Fourteen of the lines are blank.
There is also a third part, in the Inherit directory. It shows how Perl does method inheritance in object-oriented classes. You should do the exercises there last.
The module-tutorial.tar.gz and module-tutorial.zip files contain everything from all three directories.
Best of luck.
Author: M-J. Dominus
With useful suggestions and improvements from: