5/4 In perl, how do you know if an argument given is a scalar, hash,
or array?
\_ generally, the use to which it's being put. And the behaviour
you see if you use it as a scalar. Maybe use strict or -wT
might give you some helpful messages. -beginning/intermediate
perl user
\_ TYPES ARE FOR THE WEAK!
\_ or for coders who don't know what they are coding
\_ More to the point is why do you think you'd need to know in perl?
\_ say you want to overload a method so it takes different
arguments for backward compatibility. CGI.pm does that.
\_ Don't know enough about perl to know, but perhaps for things
like polymorphic function arguments? Perl is pretty ambigious
about stuff like this... which is why I avoid using it for
"real" code in projects.
\_ in some cases you might be able to use ref($var) to find out
what "type" of variable was passed: some of the return values
are SCALAR, ARRAY, HASH and REF. (man perlfunc and search for
ref). |