Heh, thanks.  I'm trying to get three things straight in my head at once:
perl OOP, the Convert::ASN1 module (thanks, Graham!), and the ISO 10161
protocol....

My brain hurts.  :-)

-David


> -----Original Message-----
> From: Brad Baxter [SMTP:[EMAIL PROTECTED]
> Sent: 2003-Jun-24 2:52 PM
> To:   [EMAIL PROTECTED]
> Subject:      Re: perl OOP question
> 
> On Mon, 23 Jun 2003, David Christensen wrote:
> > I've built a some classes (eg: ILLString) which live in ./ISO/types
> > The class "header" is:  Package ISO::types::ILLString
> > 
> > Everything in my test program works fine if (in the top-level directory)
> I 
> > say:
> > 
> > use ISO::types::ILLString;
> > my $s = new ISO::types::ILLString("This is a string");
> > 
> > Is there any way I can just say:
> > 
> > use ISO::types::ILLString;
> > my $s = new ILLString("This is a string");
> 
> I think the short answer is 'no', because the name of the package is the
> name of the class.  So your class is NOT "ILLString", it's
> "ISO::types:ILLSring".
> 
> Whether you use the "indirect object" form of method call as you're doing
> above, or the "object-oriented" form, the class name determines where Perl
> will find the new() method.  Since there isn't a class named literally
> "ILLString", Perl will complain about the latter call above (as you've no
> doubt discovered).
> 
> The "object-oriented" form of method call would look like this:
> 
> my $s = ISO::types::ILLString->new("This is a string");
> 
> To me, this better emphasizes that the class name is ISO::types::ILLString
> and the method name is new().  In either form, the class name will be seen
> by the new() method as it's first parameter.  Of course, Perl will still
> complain about this:
> 
> my $s = ILLString->new("This is a string");
> 
> because still "ISO::types::ILLString" and "ILLString" are two completely
> different class names.
> 
> Good luck wrapping your head around oop.  Before Perl5, I couldn't "get"
> the whole oop idea.  After seeing how Perl implements it, I finally
> realized what a fundamentally simple thing it is, that an object is just a
> data structure, and Perl knows where to find its methods because of the
> class it belongs to.  Of course, when you're still in the fog, that might
> not shine much light either.  :-)
> 
> Regards,
> 
> Brad

Reply via email to