in reply to Function that accepts both hashes/arrays and hashrefs/arreyrefs
Now, on to your actual question...
You can use ref to test whether your first argument is a scalar, a hashref, or an array ref to get some multi-style support, but, if the first argument is a scalar, you have no way to determine whether it's the first element of an array or the first key in a hash, since arrays and hashes are both passed in as plain lists. (I suppose you could test the size of @_, which would tell you it's an array if there are an odd number of elements, but you'd still just be taking a shot in the dark if it's even.)
|
|---|