This does not make sense imo, but ref can return (at least) four different values for an (unblessed) scalar reference: SCALAR is the most common, but GLOB, REF, LVALUE can also appear:
DB<1> x ref(\($x=5))
0 'SCALAR'
DB<2> x ref(\($x=\$x))
0 'REF'
DB<3> x ref(\*x)
0 'GLOB'
DB<5> x ref(\substr("foo",1,1))
0 'LVALUE'
Update: I didn't say why it doesn't make sense. Here's why: ref($x) can change even if $x itself does not change. Look:
perl -we '$x = \$y; for $z ( 2, \5, *u, vec(2,1,1) ) { $y = $z; warn r
+ef($x), " ", $x; }'
And the result is:
SCALAR SCALAR(0x813c4d0) at -e line 1.
REF REF(0x813c4d0) at -e line 1.
GLOB GLOB(0x813c4d0) at -e line 1.
SCALAR SCALAR(0x813c4d0) at -e line 1.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.