Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: What's in a Reference?

by almut (Canon)
on Jul 15, 2010 at 07:19 UTC ( [id://849715]=note: print w/replies, xml ) Need Help??


in reply to What's in a Reference?

use Devel::Peek; my $x = 42; my $y = \$x; Dump $y; __END__ SV = RV(0x63fde0) at 0x604fc0 REFCNT = 1 FLAGS = (PADBUSY,PADMY,ROK) RV = 0x604fa0 <--- SV = IV(0x62de60) at 0x604fa0 REFCNT = 2 FLAGS = (PADBUSY,PADMY,IOK,pIOK) IV = 42

I'd call it an address.  But in contrast to a C pointer, a Perl reference also maintains other info, and doesn't allow you to directly fiddle with the address.

(Note that the SV ... at 0x604fa0 is not part of the reference itself — Devel::Peek just dumps the referenced target, too, for convenience.)

Replies are listed 'Best First'.
Re^2: What's in a Reference?
by ikegami (Patriarch) on Jul 15, 2010 at 07:30 UTC
    Different question than last night. He's asking for the relation between the following and $y.
    SV = RV(0x63fde0) at 0x604fc0 REFCNT = 1 FLAGS = (PADBUSY,PADMY,ROK) RV = 0x604fa0 SV = IV(0x62de60) at 0x604fa0 REFCNT = 2 FLAGS = (PADBUSY,PADMY,IOK,pIOK) IV = 42 <---

      Well, I don't know what was being discussed last night, but I understand the question kind of like this:

      "A C reference/pointer holds an address, what would you call the analogous thing which a Perl reference holds?"  As the subject says: "What's in a reference?"

      Anyhow, only Xiong call tell what he really meant.

        Ah right, I thought he asked

        $3 = 3; $2 = \$3; 3 is the ________ of $2

        instead of

        $3 = 42; $2 = \$3; 3 is the ________ of $2

        There's not even a 3 in his setup.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2024-04-24 08:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found