in reply to Re: Where to find info on low level perl internals names?
in thread Where to find info on low level perl internals names?

Note that there is actually TWO different types of content for IO that differ only slightly in internal storage, but a lot in behavior. There are open files (including sockets and scalar-IO) and open directories. The difference is invisible from the outside:

$ perl -MDP -we'open DH,$0;DDump*DH' SV = PVGV(0x11d7dc0) at 0x76a5e0 REFCNT = 3 FLAGS = (MULTI) NAME = "DH" NAMELEN = 2 GvSTASH = 0x74af48 "main" GP = 0x771bc0 SV = 0x0 REFCNT = 1 IO = 0x76a5f8 FORM = 0x0 AV = 0x0 HV = 0x0 CV = 0x0 CVGEN = 0x0 LINE = 1 FILE = "-e" FLAGS = 0x2 EGV = 0x76a5e0 "DH" $ perl -MDP -we'opendir DH,".";DDump*DH' SV = PVGV(0x11d7e00) at 0x76a5f0 REFCNT = 3 FLAGS = (MULTI) NAME = "DH" NAMELEN = 2 GvSTASH = 0x74af48 "main" GP = 0x771b30 SV = 0x0 REFCNT = 1 IO = 0x76a620 FORM = 0x0 AV = 0x0 HV = 0x0 CV = 0x0 CVGEN = 0x0 LINE = 1 FILE = "-e" FLAGS = 0x2 EGV = 0x76a5f0 "DH"

Enjoy, Have FUN! H.Merijn

Replies are listed 'Best First'.
Re^3: Where to find info on low level perl internals names?
by ikegami (Patriarch) on Oct 26, 2011 at 06:51 UTC

    In both case, we have scalars of the same type (PVIO). But just like an IV can hold more than one kind of data, PVIO can contain one of two types of handles. I'll clarify that in my table.

    By the way, you didn't show the difference, so here goes:

    $ perl -MDevel::Peek -we'open FH,$^X; Dump *FH{IO}' SV = IV(0x7564a8) at 0x7564b0 REFCNT = 1 FLAGS = (TEMP,ROK) RV = 0x7693f0 SV = PVIO(0x76ccb8) at 0x7693f0 REFCNT = 2 FLAGS = (OBJECT) STASH = 0x768b68 "IO::File" IFP = 0x763b30 OFP = 0x0 DIRP = 0x0 LINES = 0 PAGE = 0 PAGE_LEN = 60 LINES_LEFT = 0 TOP_GV = 0x0 FMT_GV = 0x0 BOTTOM_GV = 0x0 TYPE = '<' FLAGS = 0x0 $ perl -MDevel::Peek -we'opendir DH,"."; Dump *DH{IO}' SV = IV(0x759d18) at 0x759d20 REFCNT = 1 FLAGS = (TEMP,ROK) RV = 0x76cc78 SV = PVIO(0x770528) at 0x76cc78 REFCNT = 2 FLAGS = (OBJECT) STASH = 0x76c3d8 "IO::File" IFP = 0x0 OFP = 0x0 DIRP = 0x7a7330 LINES = 0 PAGE = 0 PAGE_LEN = 60 LINES_LEFT = 0 TOP_GV = 0x0 FMT_GV = 0x0 BOTTOM_GV = 0x0 TYPE = '\0' FLAGS = 0x0

      You're example shows the difference. You can only get to that when *explicitly* looking at the IO glob part. I wanted to stress that when not doing so, you cannot see it. Together this is valuable information :)


      Enjoy, Have FUN! H.Merijn
Re^3: Where to find info on low level perl internals names?
by Anonymous Monk on Oct 26, 2011 at 21:36 UTC

    Thanks again!

    I'm kinda laughing at myself, and you might enjoy the laugh as well, so I might as well share... I spent a few minutes staring at the output of those two commands you posted trying to spot "the difference." ;)

    (sigh) sometimes I make myself wonder.