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
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
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
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
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
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
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,
-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
[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
: 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
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
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()
12 matches
Mail list logo