Object-Oriented Programming in Perl
Software version | 5.10 |
Website | Perl Website |
Introduction
Object-Oriented Programming (which we will refer to as OOP) is a concept with numerous universally recognized virtues today. It’s a programming method that helps improve application and software development and maintenance, with significant time savings. It’s important to keep in mind that it doesn’t reject structured (or procedural) programming since it’s built upon it. The classic approach to introducing OOP into an existing language is through encapsulation of existing functionality. The C++ language was built on C and brought OOP. The JAVA language is based on C++ syntax.
Perl has also followed suit by offering extensions to give its fans the ability to use this programming paradigm. Nevertheless, Perl being permissive, it’s not as strict as “pure object” languages. But this is normal, as Perl’s philosophy is maintained, “there is more than one way to do it” (TIMTOWTDI).
I was strongly inspired by this tutorial1, but I’ll only use a part of it for quick implementation. If you want a more condensed version that nevertheless requires good foundations, there is this one2.
Simple Example
Let’s start with a simple example including a module (because it’s mandatory) and we’ll see how to send information to it:
(Personne.pm
)
|
|
And then you have your main program:
(soft.pl
)
|
|
References
Last updated 13 Oct 2012, 20:15 CEST.