
japhy
Enthusiast
/ Moderator
Sep 6, 2000, 2:56 PM
Post #2 of 2
(42571 views)
|
I'll answer as much as I can here. I don't have time to write a full article on it, since I have other things in the works. First, as far as exporting functions and variables, have a GOOD READ through the Exporter.pm docs. They explain how to use the Exporter module, and the @EXPORT, @EXPORT_OK, and %EXPORT_TAGS variables. Inheritance is far easier in Perl than, say, C++. None of this private/protected/public nonsense: <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> package BaseClass; sub new; # you do have to actually DEFINE these functions... sub this; sub that; package SubClass; @ISA = qw( BaseClass ); sub new; sub this; package main; $a = SubClass->new; $a->that(); # SubClass does not provide a 'that' method # but SubClass inherits from BaseClass, which # does have a 'that' method # the equivalent call is similar to # BaseClass::that($a); </pre><HR></BLOCKQUOTE> A class can inherit from many other classes. The order of base-class searching is depth-first. That is, first check $ISA[0]'s methods. If not there, if that class has an @ISA tree, go through THAT, and so on. If no match is found, go to $ISA[1]. Hmm. That's all for now. You might see an article from me in a couple of months. ------------------ Jeff "japhy" Pinyan -- accomplished author, consultant, hacker, and teacher
|