in reply to Reference found where even-sized list expected

It looks like the sub returns a hash ref, and you try to store it in a hash.

There are two ways around it

# 1) store it in a reference: my $hashref = correlation(\@primarys_array, @secondarys_array); # 2) deference it and store it in a hash: my %hash = %{ correlation(\@primarys_array, @secondarys_array) };

I recommend the first one, though.

See perlreftut for more details.