Xiong has asked for the wisdom of the Perl Monks concerning the following question:
Note: If you're unsure what a reference is, better check perlreftut and perlref. This node is not about Perl syntax or internals; it is about the English-ish jargon used to discuss references and related concepts.
Given:
use Devel::Peek; use Perl6::Form; my $dog; my $cat; my $bob; my $sue; { my $pest = 'flea'; $dog = \$pest; $cat = \$pest; $bob = \$dog; $sue = \$cat; } ### say q{}; say 'Dump $dog:'; Dump $dog; say q{}; say 'Dump $cat:'; Dump $cat; say q{}; say 'Dump $bob:'; Dump $bob; say q{}; say 'Dump $sue:'; Dump $sue; say q{}; ### say q{}; say q*| $ $$ $$$ + |*; say q*|-------------------------------------------------------------- +-----|*; print form qq*|dog {<<<<<<<<<<<<<<<} {<<<<<<<<<<<<<<<} + |*, $dog, $$dog, qq*|cat {<<<<<<<<<<<<<<<} {<<<<<<<<<<<<<<<} + |*, $cat, $$cat, qq*|bob {<<<<<<<<<<<<<<<} {<<<<<<<<<<<<<<<} {<<<<<<<<< +<<<} |*, $bob, $$bob, $$$bob, qq*|sue {<<<<<<<<<<<<<<<} {<<<<<<<<<<<<<<<} {<<<<<<<<< +<<<} |*, $sue, $$sue, $$$sue, ; ## end form say q*|-------------------------------------------------------------- +-----|*; say q{}; ### my $t = 'A'; print qq*|$t| *; $t++; say q* $dog eq $cat: *, $dog eq $cat; print qq*|$t| *; $t++; say q* $$dog eq $$cat: *, $$dog eq $$cat; print qq*|$t| *; $t++; say q* $bob eq $sue: *, $bob eq $sue; print qq*|$t| *; $t++; say q* $$bob eq $$sue: *, $$bob eq $$sue; print qq*|$t| *; $t++; say q* $$$bob eq $$$sue: *, $$$bob eq $$$sue; #say $pest; say q{}; __END__ Output: Dump $dog: SV = RV(0xa080f4c) at 0xa080f40 REFCNT = 2 FLAGS = (PADMY,ROK) RV = 0xa216eb8 SV = PV(0x9fbb6d8) at 0xa216eb8 REFCNT = 2 FLAGS = (PADMY,POK,pPOK) PV = 0xa21cff0 "flea"\0 CUR = 4 LEN = 8 Dump $cat: SV = RV(0xa08148c) at 0xa081480 REFCNT = 2 FLAGS = (PADMY,ROK) RV = 0xa216eb8 SV = PV(0x9fbb6d8) at 0xa216eb8 REFCNT = 2 FLAGS = (PADMY,POK,pPOK) PV = 0xa21cff0 "flea"\0 CUR = 4 LEN = 8 Dump $bob: SV = RV(0x9fdd9a4) at 0x9fdd998 REFCNT = 1 FLAGS = (PADMY,ROK) RV = 0xa080f40 SV = RV(0xa080f4c) at 0xa080f40 REFCNT = 2 FLAGS = (PADMY,ROK) RV = 0xa216eb8 SV = PV(0x9fbb6d8) at 0xa216eb8 REFCNT = 2 FLAGS = (PADMY,POK,pPOK) PV = 0xa21cff0 "flea"\0 CUR = 4 LEN = 8 Dump $sue: SV = RV(0x9fdd8f4) at 0x9fdd8e8 REFCNT = 1 FLAGS = (PADMY,ROK) RV = 0xa081480 SV = RV(0xa08148c) at 0xa081480 REFCNT = 2 FLAGS = (PADMY,ROK) RV = 0xa216eb8 SV = PV(0x9fbb6d8) at 0xa216eb8 REFCNT = 2 FLAGS = (PADMY,POK,pPOK) PV = 0xa21cff0 "flea"\0 CUR = 4 LEN = 8 | $ $$ $$$ | |-------------------------------------------------------------------| |dog SCALAR(0xa216eb8) flea | |cat SCALAR(0xa216eb8) flea | |bob REF(0xa080f40) SCALAR(0xa216eb8) flea | |sue REF(0xa081480) SCALAR(0xa216eb8) flea | |-------------------------------------------------------------------| |A| $dog eq $cat: 1 |B| $$dog eq $$cat: 1 |C| $bob eq $sue: |D| $$bob eq $$sue: 1 |E| $$$bob eq $$$sue: 1
Uncommenting the line say $pest; raises a compile-time strict exception, of course; that package $pest is not my $pest. I do this only to make clear that I'm not concerned about this in the least. I don't care what is or is not in scope; only what to call stuff when speaking English to you (for some value of 'English').
This is a fill-in-the-blanks question. Please choose words you want to use to talk about the things in the blanks.
Please be kind enough to number your picks according to the numbered blanks. It's okay to use the same word to fill in more than one blank if you consider the relationships expressed equivalent. You don't need to fill in all of the blanks for your reply to be useful. Thank you.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: What's Really in a Reference?
by pemungkah (Priest) on Jul 16, 2010 at 23:16 UTC | |
by Xiong (Hermit) on Jul 17, 2010 at 05:48 UTC |