It would probably help you to work through the examples in perlboot, with attention to the section Invoking an instance method.
When you call your method using $regr->get_mean_x, the instance is provided as an argument. Your method function can use this to access instance variables.
sub get_mean_x { my $self = shift; my $raw_dataPtr = $self->{raw_data}; my $counter = 1; my $x_total = 0; print "raw_datePtr: $raw_dataPtr\n"; foreach my $x (keys %$raw_dataPtr) { ++$counter; $x_total += $x; } my $mean_x = ($x_total/$counter); $self->{'mean_x'} = $mean_x; return ($self->{'mean_x'}); }
In reply to Re: basic OOP question
by ig
in thread basic OOP question
by o2bwise
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |