http://qs1969.pair.com?node_id=814650


in reply to covariance calculation

What the other monks answered is correct, and here's a little addition:

The names of the variables $arraylref and $array2ref are hints that both of them are supposed to be references to arrays. \@sales is an array reference: the @ stands for "array" and \ stands for "reference". @hits, on the other hand, is just an array, not a reference.

Of course, you can't always count on variable names to hint at what they are supposed to be, but in this case it is correct.

Another hint that both of these variables really need to be references is the usage of the arrow operator -> in the line

$arraylref->[$i] * $array2ref->[$i];

The arrow operator is only used with references.