Exercises, examples and other material relating to training module P213. This topic is presented on public course Perl for Larger Projects
In Perl, you can define a class of objects in a module. All the standard Object Oriented facilities are available, and we start with constructors, destructors, instances and accessor methods.
Related technical and longer articlesIs Perl truly an OO language?Object Orientation in Perl - First Steps
Tips and short articles on this subject
Examples from our training material
|3cl|| Object Orientation - 2 classes and polymorphism|
|antest|| Introduction to Objects |
|at2|| Hello Perl Object World|
|bd1.pm|| A simple class, using a scalar to store object information|
|bd2.pm|| A simple class, using a list to store information about each object|
|bd3.pm|| A simple class, storing each object in a hash|
|big|| How Object Inheritance is done in Perl|
|blessing|| Blessing and resultant polymorphism|
|book.pm|| A simple class with a constructor and 2 access methods|
|ce.pm|| Object interface to call events|
|commute.pm|| commute.pm - used in factory demo|
|higloo|| houses and igloos - an OO example|
|housing.pm|| Definition of house, castle and igloo classes|
|journey|| Call to factory class. See ramble.pm and commute.pm|
|massage.pl|| Template object and test program|
|medium|| OO with inheritance demonstrated|
|message.htp|| Sample template for use in other demos|
|message.pl|| None-OO example of template filling|
|need1|| calling subs via bare words|
|need2|| Solving the bare word|
|nsp|| variables in packages (autovivification!)|
|oco|| Using the house, castle and igloo classes|
|peeps.pm|| Definition of two classes and polymorphism|
|ramble.pm|| A class that includes a factory method|
|roar|| Sample program to use room.pm|
|room.pm|| A simple class which uses a blessed hash|
|scemail|| quick check of email address format|
|small|| True OO example |
|spammer|| Using global matching to extract all matches|
|thing.pm|| Generic class for use during exercises|
|tiny|| Towards OO in Perl|
|ub2|| A test program to use the "book" class|
|ub3|| Another test program to use the book class|
|ubany.pl|| Test program for ub1 ub2 and ub3 classes|
|usebook|| Sample application, constructs and uses book objects|
|wheretogo|| Example that uses commute.pm and ramble.pm|
Some modules are available for download
as a sample of our material or under an Open Training Notes License
for free download from http://www.training-notes.co.uk
Topics covered in this module
Resume - using a class.
Background to instance variables - pointers and references.
new - the constructor.
Other methods in a class.
Using more complex structures to store data in a class.
Extended capabilities by using hashes.
If you are looking for a complete course and not just a information on a single subject, visit our Listing and schedule
Well House Consultants specialise in training courses in
. We run
throughout the UK (and beyond for longer courses), and
at our training centre in Melksham, Wiltshire, England.
It's surprisingly cost effective to come on our public courses -
even if you live in a different
country or continent to us
We have a technical library of over 700 books on the subjects on which we teach.
These books are available for reference at our training centre. Also
available is the Opentalk
Forum for discussion of technical questions.