Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Answer: How can I make one class extend another one?

by chromatic (Archbishop)
on Apr 20, 2000 at 20:40 UTC ( #8188=categorized answer: print w/replies, xml ) Need Help??

Q&A > object-oriented programming > How can I make one class extend another one? - Answer contributed by chromatic

Inheritance is very easy in Perl. Assuming we have a class PerlMonk, we could create a new class called vroom that extends the first:
package vroom; @ISA = qw ( PerlMonk );
From then on, for any method called on an instance of vroom that isn't defined immediately in the class, Perl will search the classes named in @vroom::ISA for those methods.

That is, PerlMonk::dispense_wisdom() is available via $vroom->dispense_wisdom() even if there is no vroom::dispense_wisdom().

Note that the @ISA array can contain lots of parent classes. Note also that they are searched left-to-right, depth first.

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
[LanX]: you don't see the whole picture
[LanX]: But reu germans have no humor, better to refrain from this site till the troll is gone...
[LanX]: true
[shmem]: I disagree

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (9)
As of 2017-04-27 19:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (512 votes). Check out past polls.