The tools have been provided already, but I wanted to add a comment: You can't do it perfectly unless you disallow certain special cases related to overloading. Perl is designed around of the concept of implicit coercion, so trying to use type-based polymorphism in Perl is inherently flawed.
By the way, your use of a prototype is not only unnecessary, it's wrong. You tell Perl that the sub takes no arguments ("sub xyz()"), but the sub clearly does take arguments ("while(defined($arg = shift))") and you have to tell Perl to ignore the fact that you told it the sub takes no arguments ("&xyz"). You should have
sub xyz { ... } xyz($s); xyz(\%h);
In reply to Re: How to tell if I have a string, or a ref to a hash
by ikegami
in thread How to tell if I have a string, or a ref to a hash
by mshaw
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |