OO in perl

2005-07-19 Thread Beast
Perl Object Oriented Programming is very confusing (to me at least :) --- package Test; sub new {} sub f_one{} sub f_two{} 1; --- I can call using my $test = Test-new-f_one; But why this not works? my $test = Test-new-f_one-f_two; -- --beast -- To unsubscribe, e-mail: [EMAIL

RE: OO in perl

2005-07-19 Thread Thomas Bätzler
Beast [EMAIL PROTECTED] asked: I can call using my $test = Test-new-f_one; Test-new returns an object of type Test; and so your code is equivalent to my $obj = Test-new; my $test = $obj-f_one; But why this not works? my $test = Test-new-f_one-f_two; This will work if f_one returns a

Re: OO in perl

2005-07-19 Thread Jeff 'japhy' Pinyan
On Jul 19, Beast said: package Test; sub new {} sub f_one{} sub f_two{} You've neglected to show us the contents. I'll assume that new() creates and returns an object. I'll also assume that f_one() and f_two() DO NOT return objects. my $test = Test-new-f_one; Test-new returns an

Re: Attempting OO with Perl - New() method in subclass not working

2005-04-02 Thread Randal L. Schwartz
Brad == Brad Carlson [EMAIL PROTECTED] writes: Brad Just to clarify, the only reason I don't need a new() method in the Brad subclass is because any class-specific logic is contained in the _init() Brad method for both parent and subclass. If there were no _init() method, Brad then both classes

Re: Attempting OO with Perl - New() method in subclass not working

2005-04-01 Thread Randal L. Schwartz
Jeff == Jeff 'japhy' Pinyan [EMAIL PROTECTED] writes: Jeffsub new { Jeff my $that = shift; Jeff my $class = ref($that) || $that; Jeff my $self = $class-SUPER::new(); Jeff $self-SUPER::_init(); There's a rule of thumb from smalltalk that if you're using a super call with

Re: Attempting OO with Perl - New() method in subclass not working

2005-04-01 Thread Jeff 'japhy' Pinyan
On Apr 1, Randal L. Schwartz said: Jeff == Jeff 'japhy' Pinyan [EMAIL PROTECTED] writes: Jeffsub new { Jeff my $that = shift; Jeff my $class = ref($that) || $that; Jeff my $self = $class-SUPER::new(); Jeff $self-SUPER::_init(); There's a rule of thumb from smalltalk that if

Re: Attempting OO with Perl - New() method in subclass not working

2005-04-01 Thread Randal L. Schwartz
Jeff == Jeff 'japhy' Pinyan [EMAIL PROTECTED] writes: Jeff Oh, right. April Fool? ;) Perhaps that's half right. :) -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 merlyn@stonehenge.com URL:http://www.stonehenge.com/merlyn/ Perl/Unix/security consulting,

RE: Attempting OO with Perl - New() method in subclass not working

2005-04-01 Thread Brad.Carlson
-DBLogon::_init(); return $self; } Thanks again, I've been fighting this for quite a while. -Original Message- From: Jeff 'japhy' Pinyan [mailto:[EMAIL PROTECTED] Sent: Thursday, March 31, 2005 7:18 PM To: [EMAIL PROTECTED] Cc: beginners@perl.org Subject: Re: Attempting OO with Perl

RE: Attempting OO with Perl - New() method in subclass not workin g

2005-04-01 Thread Bob Showalter
[EMAIL PROTECTED] wrote: I am trying to build an inheritable object, and I am using examples from the Perl Cookbook, 2nd edition, mostly Recipe 13.1, using the new and _init methods. Your subclass does not need (and should not have) a new() method; it can use the one from the base class. As

RE: Attempting OO with Perl - New() method in subclass not working

2005-04-01 Thread Brad.Carlson
: Attempting OO with Perl - New() method in subclass not working [EMAIL PROTECTED] wrote: I am trying to build an inheritable object, and I am using examples from the Perl Cookbook, 2nd edition, mostly Recipe 13.1, using the new and _init methods. Your subclass does not need (and should not have

Attempting OO with Perl - New() method in subclass not working

2005-03-31 Thread Brad.Carlson
I am trying to build an inheritable object, and I am using examples from the Perl Cookbook, 2nd edition, mostly Recipe 13.1, using the new and _init methods. I created a base class Logon and a subclass called DBLogon, in files Logon.pm and DBLogon.pm, respectively. All referenced files are

Re: Attempting OO with Perl - New() method in subclass not working

2005-03-31 Thread Jeff 'japhy' Pinyan
On Mar 31, [EMAIL PROTECTED] said: When I try to assign values to the DBLogon object's attributes, I get the following error: Can't access 'USERID' field in object of class DBLogon at testdblogon.pl line 7. What am I missing? The problem is that Logon's new() method is calling LogonDB's _init()