in reply to basic OOP question

There are a few things you will want to change with this code. Overall the code you need is there. With a few tweaks you should end up with something working like this:
use strict; package regression; sub new { my ($class, $raw) = @_; bless { 'raw_data' => $raw, 'mean_x' => 0, 'mean_y' => 0, 'slope' => 0, 'y_intercept' => 0 }, $class; } sub get_mean_x { my $self = shift; my $raw_dataPtr = $self->{'raw_data'}; my $counter = 1; my $x_total = 0; for my $x (keys %$raw_dataPtr) { ++$counter; $x_total += $x; } $self->{'mean_x'} = $x_total / $counter; } package main; my ($mean_x,$mean_y,$slope,$y_intercept); my %raw_data = ( 1 => 100, 2 => 160, 2.5 => 182, 3 => 225 ); my $regr = regression->new(\%raw_data); $mean_x = $regr->get_mean_x; print "Mean_x: $mean_x\n";