in reply to Passing reference to subroutine

For starters, $#array doesn't return the length, but the index of the last element (one less than length).

Dereferencing Syntax shows how simple it is to convert to using a reference. References Quick Reference goes into more detail.

What was
$#array
becomes
$#{ $ref }
which can also be written as
$#$ref

And if you want the size of the array,
@array (in scalar context)
becomes
@{ $ref }
which can also be written as
@$ref