YNOT
  • Home
  • Industry News
    • Adult Business News
    • Adult Novelty News
    • YNOT Magazine
    • EU News
    • Opinions
    • Picture Galleries
  • PR Wire
    • Adult Company News
    • Adult Retail News
    • Adult Talent News
    • Adult Videos News
  • Podcasts
  • Industry Guides
    • Adult Affiliate Guide
    • Affiliate Marketing for Beginners
    • Top Adult Traffic Networks
    • Top Adult PR Agents
    • Funding an Adult Business
  • Business Directory
    • View Categories
    • View Listings
    • Submit Listing
  • Newsletters
  • Industry Events
    • Events Calendar
    • YNOT Cam Awards | Hollywood
    • YNOT Awards | Prague
    • YNOT Cammunity
    • YNOT Summit
    • YNOT Reunion
  • Login with YNOT ID
YNOT University: Educational articles and tutorials

Perl and Object Oriented Programming

Posted On 28 Jul 2000
By : admin

“Hereby you reduce the time it takes to code, hence, making you more productive!”In a previous article I mentioned perl modules, and how modularising your code can be a good thing. We’re going to take it a step further this time and discuss Perl Objects. Perl’s definition of an object is very simple: “An Object is a reference to a thingie that belongs to another thingie”.

Says much doesn’t it? What it comes down to – an object is a variable that belongs to a specific class. An example:


package MyThingie;

sub new {
my $that=shift;
my $this=ref($that) || $that;
my $self={};
bless($self, $this);
return $self;
}

Basically, what that did is create an object. You use that one as follows:


use MyThingie;
$thing=new MyThingie;

There you go. You blessed ‘thing’ into the ‘MyThingie’ class. Now, the fun part about objects is that you can move them around at will. If I wanted 10 MyThingie objects, I could create 10 and push them into an array. You can also store variables and methods inside an object, like this:


package MyThingie;

sub new {
my $that=shift;
my $this=ref($that) || $that;
my $self={“thingie” => “something”};

bless($self, $this);
return $self;
}

sub what {
my $self=shift;
my $what=shift;

return $self->{what};
}

Using the above usage example, you would be able to do this:


$something=$thingie->what();

$something would now contain ‘something’. Objects are especially useful for writing skeleton applications, that is, provide all the functions necessary for an application to work. Since you can now easily create multiple frontends for applications using the same object.

“Hereby you reduce the time it takes to code, hence, making you more productive!”

Another fun trait about objects is that they can ‘inherit’ from other objects. Taking the above MyThingie object, we can make another object that inherits from that class by simply using this:


package AnotherThingie;
use MyThingie;

@ISA=qw(MyThingie);
sub that {
my $self=shift;

print(“That’s nice\n”);
}

This AnotherThingie class will inherit all methods from the MyThingie class (including it’s constructor ‘new’ and the ‘what’ function) and adds a new ‘that’ function:


use AnotherThingie;

$anotherthingie=new AnotherThingie;
print($anotherthingie->what);
$anotherthingie->that;

See how easy that was? This is the key to objects. You can now write very complicated applications in a short matter of time!

You can have a base class to access a database for you and give it enough functions to be able to connect, store, and retrieve data. On top of that class, you can build a new class that will do exactly what you want it to do for any given application. Hereby you reduce the time it takes to code, hence, making you more productive!

Reader Comments on this Article:

Comment by:Summary:
StephenI *Still* Don’t Get It! ™

  • google-share
Previous Story

Another New Pay Site?

Next Story

FrontPage F*ck-Ups – And What To Do About Them

Leave a Reply Cancel reply

You must be logged in to post a comment.

Sponsor

YNOT Shoot Me

YNOTShootMe.com has exclusive pics from adult industry business events. Check it out!

YNOT Directory

  • iWantClips
    Online Content Providers
  • Linkdolls
    Online Retail Stores
  • Smart Pix Manager
    Software & Scripts
  • Premiere Listing

    delevit – remove your leaked content

    More Details

RECENT

POPULAR

COMMENTS

Bad Bella Gets Unwrapped in New MYLF Scene

Posted On 03 Jul 2025

Parker Savage Gets Extra Sweaty with Newbie Lola Cheeks

Posted On 03 Jul 2025

Sofie Marie Gets Down on Analyst’s Couch in New YummyGirl Scene

Posted On 03 Jul 2025

Vanessa, Meet Vivid

Posted On 29 Sep 2014
Laila Mickelwaite and Exodus Cry

Laila Mickelwaite, Exodus Cry and their Crusade Against Porn

Posted On 03 May 2021

Sex Toy Collective Dildo Sculptor

Posted On 19 Mar 2019

Find a good sex toy is now a problem,...

Posted On 18 Mar 2024

Thanks to the variety of sex toys, I can...

Posted On 02 Feb 2024

I understand the concerns about...

Posted On 05 Jan 2024

Sponsor

Sitemap
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.OkPrivacy Policy