<?xml version="1.0" encoding="windows-1252"?>
<node id="246" title="perlfunc:ref" created="1999-08-24 18:42:30" updated="2005-08-12 21:05:46">
<type id="119">
perlfunc</type>
<author id="114">
gods</author>
<data>
<field name="doctext">
</field>
<field name="name">

&lt;P&gt;
ref - find out the type of thing being referenced

&lt;P&gt;
&lt;HR&gt;
</field>
<field name="synopsis">

&lt;P&gt;
ref 
&lt;FONT SIZE=-1&gt;EXPR&lt;/FONT&gt;

&lt;P&gt;
ref

&lt;P&gt;
&lt;HR&gt;
</field>
<field name="description">

&lt;P&gt;
Returns a 
&lt;FONT SIZE=-1&gt;TRUE&lt;/FONT&gt; value if 
&lt;FONT SIZE=-1&gt;EXPR&lt;/FONT&gt; is a reference, 
&lt;FONT SIZE=-1&gt;FALSE&lt;/FONT&gt; otherwise. If 
&lt;FONT SIZE=-1&gt;EXPR&lt;/FONT&gt; is not specified,
 &lt;CODE&gt;$_&lt;/CODE&gt; will be used. The value returned depends on the type of thing the reference
is a reference to. Builtin types include:

&lt;P&gt;
&lt;PRE&gt;    REF
    SCALAR
    ARRAY
    HASH
    CODE
    GLOB
&lt;/PRE&gt;
&lt;P&gt;
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 &lt;CODE&gt;typeof()&lt;/CODE&gt; operator.

&lt;P&gt;
&lt;PRE&gt;    if (ref($r) eq &amp;quot;HASH&amp;quot;) {
        print &amp;quot;r is a reference to a hash.\n&amp;quot;;
    }
    if (!ref($r)) {
        print &amp;quot;r is not a reference at all.\n&amp;quot;;
    }
&lt;/PRE&gt;
&lt;P&gt;
See also [perlman:perlref|the perlref manpage].

&lt;HR&gt;
</field>
</data>
</node>
