On Wed, Jul 18, 2001 at 03:59:14PM -0000, [EMAIL PROTECTED] wrote:
> 
> #how to set an accessmethod
> sub accessmethod{
> 
> my $self = shift;
> 
> if (@_) { $self->[ACCESS_METHOD] = shift }
> return $self->[ACCESS_METHOD];
> 
> }#end accessmethod
> 
> 
> #here the problem occurs when trying to update an instance variable.
> 
> sub add_time{
> my $self = shift;
> my ($seconds) = @_;
> 
> #the problem is that now access method is also set to seconds!!!!!
> $self->[$TOTAL_ACCESS_TIME] += $seconds;
> }

You haven't managed to set ACCESS_METHOD and $TOTAL_ACCESS_TIME to the
same value, have you?

Did you mean $TOTAL_ACCESS_TIME (with the $)?  You are using strict and
warnings, right?  If not, $TOTAL_ACCESS_TIME might be undefined, and
ACCESS_METHOD might return 0.

Unless you are desperate for that last little bit of memory or speed you
should probably be basing your object on a hash rather than an array.

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to