Prototypes won't really help here. All they do is coerce the passed arguments into what you're expecting. You still have to document the API carefully so people are enlightened as much as possible. (I almost never use them.)
My point is that with using references directly, you'll get a better error message. If you're expecting an array reference and someone passes a hash reference, Perl will complain that you're doing arrayish operations on something that doesn't look like a hash. (If you're lucky, you won't get one of the obscure pseudohash errors...)
I'm not sure what you mean by figure out what type of variable a typeglob is aliasing to. You can use defined and exists on the typeglob slot to see if something's there and usable, but that has other subtleties and optimizations.
Checking the reference type with ref or UNIVERSAL::isa() is much better. It's much simpler.
In reply to Re: Re: Confused about typeglobs and references
by chromatic
in thread Confused about typeglobs and references
by Argel
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |