in reply to How to combine these 2 subroutines in one?
As a first step, have a look at ref, that let's you decide whether a variable contains a reference to an array.