Object Oriented Perl

These examples demonstrate modules/classes written in a fairly advanced style of Object Oriented Perl programming as taught by Damian Conway in his authoritative book on the subject, 'Object Oriented Perl'. I've adapted a little bit of my own style into these after taking the basic approach you will find in the first half of Mr. Conway's book. In each case, the OO module is accompanied by a procedurally-written application which implements the module. The code is heavily commented and you will find all important points covered in those comments. Additionally, I try to write my code and compose variable and object names such that the code is as self-documenting as possible and non-obfuscated.

EmSend is a module to make an SMTP connection and send an email. The sendit.pl program which accompanies the module is the procedurally-programmed application implementing it. EmSend is a little bit unique as compared to the CardDeck below in that it passes all arguments and data as a single hash reference, while CardDeck passes an actual hash flattened into a list. In both cases the parameters and data are passed in name-value pairs, but in the case of EmSend, no data is copied BUT the original data can be modified by the child routines since it was passed via reference. You may or may not want that feature and I am just playing around with techniques here. In the case of CardDeck and passing an actual hash as a list, you are actually copying the data and if you modify it in child routines you will not be modifying the parent data with which you called the method or subroutine.
EmSend - A Perl class to make an SMTP connection and send a single email. Demo app included.

CardDeck is a module/class which simulates a traditional deck of cards with the capability of dealing out a single card. The cardsim.pl program which accompanies the module is the procedurally-programmed application implementing it. CardDeck has the ability to shuffle the deck and returns any previously-dealt card to the bottom of the deck every time a new card is dealt. The deck starts out very orderly, prior to shuffling. You can shuffle the deck whether or not any card has yet been dealt. It will be simple to extend this module to simulate hands containing multiple cards and multiple hands so that a true card game can be built. The next phase would be to create an additional class for the hands themselves and even a separate class for the individual cards.
CardDeck - A Perl class which simulates a deck of playing cards. Demo app included.

Many more modules/classes and demo apps coming soon!