Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!etnibsd!vsh From: vsh@etnibsd.UUCP (Steve Harris) Newsgroups: comp.lang.perl Subject: Re: While learning PERL... a suggestion Summary: So, is this how the symbol table works? Keywords: perl file learn suggest Message-ID: <1204@etnibsd.UUCP> Date: 24 Jan 91 22:31:00 GMT References: <1991Jan19.003519.23569@ux1.cso.uiuc.edu> <1991Jan24.100539.20366@iwarp.intel.com> Organization: Eaton Corp, Semiconductor Equipment Div., Beverly, MA Lines: 38 In article <1991Jan24.100539.20366@iwarp.intel.com>, merlyn@iwarp.intel.com (Randal L. Schwartz) writes: > > I hope Larry will forgive me for the following. It's probably close > enough for jazz, but Larry will cringe at the description. > > Think of *FOO as the internal representation of the symbol "FOO" in > the program, in *whatever* form it is used: &FOO, $FOO, %FOO, @FOO, > and FOO as a filehandle. When you say *BAR = *FOO, you are really > saying that BAR can be used anywhere that FOO can be used with > identical results. It doesn't matter if there's an intermediate step: > you could say $a = *FOO then *BAR = $a. > > So assigning something to *BAR _must_ affect all object with a BAR as > their name. It's dangerous... it's not just for filehandles. Okay, is this paraphrase correct? Perl keeps a symbol table containing all the symbols (names) in your perl program. However, each entry in the symbol table **MAY** refer to a scalar, an array, a filehandle, a subroutine, etc., depending on context. Presumably, the symbol table entry for "FOO" has a pointer to a struct containing (pointers to) all the possible instances of the symbol. When you say *BAR = *FOO, you're creating a symbol table entry "BAR" which points to the same struct as the symbol table entry "FOO". So that a reference to $BAR is exactly the same as a reference to $FOO, ditto for @FOO and @BAR, etc. FOO ----+ -> scalar \ -> array -> struct -> associative array / -> subroutine BAR ----+ -> filehandle -- Steve Harris - Eaton Corp. - Beverly, MA - uunet!etnibsd!vsh