Python, Lua and Tcl - public course schedule [here]
Private courses on your site - see [here]
Please ask about maintenance training for Perl, PHP, Java, C, C++, Ruby, MySQL and Linux / Tomcat systems
Well House Consultants
You are on the site of
Well House Consultants
Open Source Training Courses
hotel accommodation. You are welcome to browse and use
our resources subject to our copyright statement and to add in links from your pages to ours.
Other subject areas - resources
Well House Manor Resources
Object Orientation and General topics
Linux / LAMP / Tomcat Resources
Well House Consultants Resources
C and C++ Resources
Web and Intranet Resources
Perl module P213
Creating your own Classes
Exercises, examples and other material relating to training module P213. This topic is presented on public courses Perl Programming
, Perl for Larger Projects
, Learning to program in Perl
, Perl Programming
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
|Articles and tips on this subject||updated|
|4607||Classes and object - first steps in Perl 6|
Perl 6 has a full object and class implementation ... first simple example [here]. Classes are defined with a class keyword, instance variables with a haskeyword, and methods with a method keyword. There's no "public", "protected", "private" wording, but subsidiary sigils (twigils) ... an extra "." ...
|2169||When should I use OO techniques?|
We have two friends. They're married. She's a keen advocate of Object Oriented Programming and he can't stand the approach. So take them to the pub, buy them a couple of drinks each, mention OO programming and watch the feathers fly ;-)
Seriously, Object Oriented Programming has its place - and there ...
|3833||Learning to use existing classes in Perl|
If you've got a whole lot of logic that you want to be able to run on data of a certain type, you'll typically put all of that logic into a grouping of its own - typically known as a package or a class, and you'll then call that logic at a high level from outside the package or class. This is a great ...
|3098||Learning Object Orientation in Perl through bananas and perhaps Moose|
Perl has the most incredbible range of OO facilities (though at times it's overfeatured and a bit old fashioned / tricky to use). So yesterday I wrote a whole series of examples ... and then went on to explore Moose - a module which adds extra keywords and lets you define your classes in a shorter ...
|3059||Object Orientation in an hour and other Perl Lectures|
I enjoy the occasional course that's different in its design and specification, and yesterday was one of those - more lectures that training, on intermediate and advanced Perl, for a group of eight delegates who were all well experienced at PHP, but Perl "dabblers" to this point. During the day, we ...
|2969||What does blessing a variable in Perl mean?|
When you "bless" a variable in Perl, what are you doing?
You are taking the address of the variable, and returning a "reference to an object" - that's a result which contains three pieces of information:
1. The address in memory at which the object is held
2. The type of Perl structure that's held there ...
|2877||Further more advanced Perl examples|
I've uploaded a further batch of new examples (that makes around 40 in total!) from the private Perl course that I ran from Wednesday through Saturday last week - many of them adding a new twist on to previous examples. If you read a comment below and thing "that's what I'm looking for an example of", ...
|2834||Teaching examples in Perl - third and final part|
Three part article ... this is part 3. Jump back to part  
Following on from two earlier posts, here is the final third of the new examples that I wrote during last week's Perl course, and to which I have added extra documentation over the last couple of days.
P212 More on Character Strings
|1925||Introduction to Object Oriented Programming|
"Object Oriented Programming" is a whole new philosophy for programmers who have been writing short scripts for years, and it can be quite frightening to learn with all these new buzzwords like "overriding", "encapsulation" and "polymorphism" creeping in. It's a beautiful concept and a lovely approach, ...
|1864||Object Oriented Perl - First Steps|
There are some occasions when a new example that I write / a topic that comes up on a course results in an article that's so long that it doesn't fit into the Blog / short article format, but requires a more substantial mechanism.
And so it is for my First steps in Object Oriented Perl examples, written ...
|1664||Example of OO in Perl|
Although Perl 5 doesn't use the words "class", "method" or "object" (or any of the other common OO words), it never the less has a very good OO model indeed - here's the source code of an example, together with the result of running the sample. I'll then give you a few clues!
|227||Bellringing and Programming and Objects and Perl|
For the second time this year (and it's only the second month), I find that I have a keen bell-ringer on my programming course ... he's off each evening to meet up with fellow bell-ringers in church towers in Wiltshire, and having a really good time outside course hours as well as during the day. I understand ...
|1435||Object Oriented Programming in Perl - Course|
Perl Review (module P251) Subroutines in Perl (module P209) More than Simple Lists and Hashes! (module P217) Object Orientation: Individual Objects (module Q906) Creating your own Classes (module P213) Object Orientation: Composite Objects (module Q909) More Objects (module P218) Object Orientation: ...
|1320||Perl for Larger Projects - Object Oriented Perl|
Perl is a powerful language for short utility scripts - AND a powerful object oriented language too, which is great if you're going to be writing longer applications and / or a suite of programs with shared code.
We run a general course that introduced Perl for everyone and also a more advanced course ...
|983||Blessing in Perl / Member variable in Ruby|
How do you decide what member variables you have in an object in Ruby? Well - in Perl, you bless a single hash (or, exceptionally, a list or a scaler), but in Ruby you refer to each variable that you wish to be a member of each object using a preceeding @ character.
|975||Answering ALL the delegate's Perl questions|
During courses, questions arise. "I'll get back to that" could make people feel that I'm brushing something off ... except that I explain, early on, that some questions require a great deal of background knowledge to be answered sensibly. And I keep a list of topics that I'll be getting back to ...
|246||When to bless a Perl variable|
Perl's bless function, which turns a reference into an instance of an object, it typically called up as the last action in a constructor method. On today's Perl for Larger Projects course, I was challenged as to when else it might be used. Here's an example - when loading a file of information into ...
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 [here]
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.