in reply to variance calculation

It means you're mixing lists and arrayrefs. You pass variance an arrayref, but you're processing @_ inside the subroutine.

If your lists of numbers are small, just use arrays/lists throughout. Otherwise, make sure you properly dereference your arrayrefs.

I'm sure CPAN has many such modules that will do these calculations for you if you want a tried & tested solution.