Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^4: ref == "REF"

by gaal (Parson)
on Oct 19, 2004 at 10:26 UTC ( [id://400460]=note: print w/replies, xml ) Need Help??


in reply to Re^3: ref == "REF"
in thread ref == "REF"

A glob is certainly not a kind of a scalar value!

The meaning of scalar is something that holds a single value. A string (seen as an object) is a single value. An array, such as an array of characters of a string, is not a single value, because it has different "slots" for different pieces of information. A glob has fields, as you say yourself, so it is not a scalar, either.

In regard to LVALUE, it means something more specific than that.

perl -l $s = '123456789'; $r = \substr $s, 0, 1; print ref $r; $$r = "x"; print $s LVALUE x23456789

I understand what's going on, but I don't know this feature well enough to comment on its general use.

Replies are listed 'Best First'.
Re^5: ref == "REF"
by Ven'Tatsu (Deacon) on Oct 19, 2004 at 15:46 UTC
    LVALUE is used internally for the 'magic' used with substr, vec, pos, keys, etc. when you use them as lvalues in an assignment. It holds (in addition to typical scalar data) a pointer to the Sv* that it can modify and what part to modify.
    PerlGuts Illustrated has a lot of information on how Sv*'s are layed out. In reguards to your original question is shows that SvRV (a struture that holds only a reference to another Sv*) is smaller than SvPV, SvPVIV, and SvPVNV, which are the 3 that I'm guessing are considered 'SCALAR' by ref. So 'REF' might indicate that the underlying structure is to small to hold a full scalar value, and would need to be upgraded to a SvPV of better to hold a non reference value. I don't know that any of that information would be of any use to Perl code, and perl handles all that on the C level so 'REF' may be only informative, or entirely redundant, depending on your viewpoint. (but as others have noted ref is less than totaly useful it self as it stands now)
    Disclaimer: I've only recently started looking at the internals of perl, I could be totaly off mark on any of this.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://400460]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (4)
As of 2024-04-25 06:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found