Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Re: LVALUE refs

by BrowserUk (Patriarch)
on Feb 16, 2003 at 19:31 UTC ( [id://235772]=note: print w/replies, xml ) Need Help??


in reply to Re: LVALUE refs
in thread LVALUE refs

Thanks for reporting your findings, I too am a great believer in empirical evidence, even if only as a prelude to verification via other routes. Deriving this understanding from the Perl sources would require considerably more familiarity than I currently have, or am likely to expend the time to aquire. Whilst I love Perl as a language, I absolutely hate having to delve into the source, it's like reading a completely different language rather than C.

<personal grouse>Effective as it is, why oh why isn't it at least indented properly. In this day an age when I routinely use a CLI window that has 160 characters of width and often push this to 200 when the need arises, why does everything have to be squashed up into the left-hand 50 chars? </personal grouse>

I'm not sure that I'll be making any use of the information though. Once you see what is involved in an LVALUE

perl> use Devel::Peek perl> $r = \substr('the quick brown fox', 10, 5) perl> print $r LVALUE(0x1bd2a70) perl> print $$r brown perl> Dump($r) SV = RV(0x1bd1cc0) at 0x1bd29f8 REFCNT = 1 FLAGS = (ROK) RV = 0x1bd2a70 SV = PVLV(0x1bc3388) at 0x1bd2a70 REFCNT = 1 FLAGS = (PADMY,GMG,SMG,pPOK) IV = 0 NV = 0 PV = 0x1bc37a8 "brown"\0 CUR = 5 LEN = 6 MAGIC = 0x1bc3338 MG_VIRTUAL = &PL_vtbl_substr MG_TYPE = 'x' TYPE = x TARGOFF = 10 TARGLEN = 5 TARG = 0x1bdf074 SV = PV(0x1bcd490) at 0x1bdf074 REFCNT = 1 FLAGS = (PADBUSY,POK,pPOK) PV = 0x1bc19f0 "the quick brown fox"\0 CUR = 19 LEN = 20

you realise that LVALUE refs are far from the 'cheap' utility that they appeared (to me at least) to be. That combined with their undocumented nature probably outweights any advantages that they might have provided.

Replies are listed 'Best First'.
Re: Re: Re: LVALUE refs
by xmath (Hermit) on Feb 16, 2003 at 19:56 UTC
    ehm, Dump() just shows it all very verbosely.. but it IS a cheap utility. Cheaper than any alternative, at least.

    All you're seeing is that $x is a reference (RV 0x1bd1cc0) to the lvalue object (PVLV 0x1bc3388) which points to the string you've taken a substring of (PV 0x1bcd490), and the lvalue object has one piece of magic to point to the functions implementing extraction and replacement of substrings. That's obviously about as simple as it can get.

    Just for fun, dump an array containing the relevant info: Dump [\'the quick brown fox', 10, 5];

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2024-04-18 23:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found