[ABE.pm] Accessing parameters in OOP
Faber J. Fedor
faber at linuxnj.com
Tue Jan 9 19:09:00 PST 2007
I just went throughthe 2006 archives looking for an OOP thread to
refresh my fuzzy memory and I couldn't find it, so I'll ask again.
Internally, I access the object's internal data like this:
$where = "where name = $self->{name} " ;
IIRC, this is A Bad Thing, right?
Do I write an method like
sub name {
my $self = shift;
if (@_) {
$self->{name} = lc(shift);
}
return $self->{name};
}
and then call it like this
$where = "where name = name() " ;
or maybe
$where = "where name = ". name() ;
How does the object know which name() to look for?
(Yes, when I'm outside the object, I do use the name() method to access
the $self->{name}).
And another thing, if I'm inside my object and I call another function
inside my object, why do I explicitly have to pass $self? Why isn't it
automagically passed in like it is with name() above?
--
Regards,
Faber Fedor
President
Linux New Jersey, Inc.
908-320-0357
800-706-0701
http://www.linuxnj.com
More information about the ABE-pm
mailing list