Path: utzoo!attcan!uunet!ogicse!iwarp.intel.com!news From: merlyn@iwarp.intel.com (Randal L. Schwartz) Newsgroups: comp.lang.perl Subject: Re: While learning PERL... a suggestion Keywords: perl file learn suggest Message-ID: <1991Jan24.100539.20366@iwarp.intel.com> Date: 24 Jan 91 10:05:39 GMT References: <1991Jan19.003519.23569@ux1.cso.uiuc.edu> <11115@jpl-devvax.JPL.NASA.GOV> <118879@uunet.UU.NET> <1991Jan21.092204.11944@ux1.cso.uiuc.edu> <1991Jan21.174520.12207@iwarp.intel.com> <1991Jan21.201845.28080@ux1.cso.uiuc.edu> Sender: news@iwarp.intel.com Reply-To: merlyn@iwarp.intel.com (Randal L. Schwartz) Organization: Stonehenge; netaccess via Intel, Beaverton, Oregon, USA Lines: 52 In-Reply-To: phil@ux1.cso.uiuc.edu (Phil Howard KA9WGN) In article <1991Jan21.201845.28080@ux1.cso.uiuc.edu>, phil@ux1 (Phil Howard KA9WGN) writes: | >You could also futz with the namespace, like: | | > *HANDLE = $filehandle[17]; | > print HANDLE "this goes to the 17th filehandle"; | | >but remember that this affects &HANDLE, %HANDLE, and @HANDLE as well. | >(I understand that this is more efficient than the indirect filehandle | >if you do more than one I/O per filehandle switch.) | | In what way does it affect them? I was getting the impression from the | man pages that these name spaces were separate. This was discussed in | the man pages with regard to passing by references, but I guess you are | now filling in the ambiguities of its affect elswhere. I'm not up on | subroutines yet (probably mostly due to not understand how the name | space works). The name spaces are separate in the ordinary sense, but the * operator is not an ordinary operator. :-) 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. Now, the one little tricky that I didn't describe so far is what I used in my previous post. Namely: that *BAR = *FOO can also be accomplished with *BAR = 'FOO', because Perl will look up FOO at runtime to figure out what it really is. Now, since the "name" FOO is quoted, you could really stick anything there, like *BAR = '42*xx', and now the name BAR is a synonym with another name 42*xx, even though that sort of name would never make it past the parser. There. Clear as mud? :-) By the way, I just got home from Uniforum. It was great. 300 books sold and signed within 2 hours. My hand is tired. :-) print do {{ redo unless "Just another Perl hacker,"; }} # huh? :-) -- /=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\ | on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III | | merlyn@iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn | \=Cute Quote: "Intel: putting the 'backward' in 'backward compatible'..."====/