in reply to covariance calculation

The error message should be a hint that your are not passing what you think. Line 14 accesses $arraylref, so clearly that contains the string "2378" instead of an array reference. $arraylref gets its value from @_ on line 12. @_ is set on the method call on line 7, where you are passing the array and not an array reference. The line should read:

my $covariance = covariance (\@hits,\@sales);

And, incidentally, you don't include the mean method you invoke on line 18 - when you post, please include all methods in your posted code.