perlfunc
gods
<P>
ref - find out the type of thing being referenced
<P>
<HR>
<P>
ref
<FONT SIZE=-1>EXPR</FONT>
<P>
ref
<P>
<HR>
<P>
Returns a
<FONT SIZE=-1>TRUE</FONT> value if
<FONT SIZE=-1>EXPR</FONT> is a reference,
<FONT SIZE=-1>FALSE</FONT> otherwise. If
<FONT SIZE=-1>EXPR</FONT> is not specified,
<CODE>$_</CODE> will be used. The value returned depends on the type of thing the reference
is a reference to. Builtin types include:
<P>
<PRE> REF
SCALAR
ARRAY
HASH
CODE
GLOB
</PRE>
<P>
If the referenced object has been blessed into a package, then that package
name is returned instead. You can think of [perlfunc:ref|ref()] as a <CODE>typeof()</CODE> operator.
<P>
<PRE> if (ref($r) eq "HASH") {
print "r is a reference to a hash.\n";
}
if (!ref($r)) {
print "r is not a reference at all.\n";
}
</PRE>
<P>
See also [perlman:perlref|the perlref manpage].
<HR>