There are two small problems with this code - The first is that you have called the subroutine depth yet reference it within the subroutine as dimensions. Has anyone ever told you that recursion is evil? :-)
Also, if the subroutine is called with something other than an array reference, it still returns a count of 1.
This code addresses the issues above and returns the correct reference depth of the array.