bug in 5.002... *SYM{THING} syntax is not documented
bug in 5.002... *SYM{THING} syntax is not documented
"Randal L. Schwartz"
Sun, 14 Apr 1996 09:49:12 -0700
- Newsgroups:
- perl.porters-gw
I'm just hacking up the object section for the new camel, and recalled
this nifty *SYM{THING} feature, so I wanted to write about it.
Durn it. It's not documented. I guess we didn't leave the Salzenberg
on long enough, or whomever hacked this in.
I can't even figure out where it lives in the source code.
Could someone please forward me the blurb that came out with the patch,
at least, or point me to the source that does it?
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: My Home Page!
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
Re: bug in 5.002... *SYM{THING} syntax is not documented
Gurusamy Sarathy
Sun, 14 Apr 1996 14:02:40 -0400
- Newsgroups:
- perl.porters-gw
- References:
- <199604141649.JAA06070@desiree.teleport.com>
On Sun, 14 Apr 1996 09:49:12 PDT, "Randal L. Schwartz" wrote:
>
>Could someone please forward me the blurb that came out with the patch,
>at least, or point me to the source that does it?
Look in pp_hot.c, line 79, pp_gelem(). Here's what I quickly came up with:
The syntax C<*SYM{THING}> can be used to get a reference to a particular
element of type "THING" within a typeglob (where "THING", as of 5.002,
is one of the following perl basic type names: C, C,
C, C, C, C). For example,
C<@{*foo{ARRAY}}> is equivalent to the dynamic array variable C<@foo>,
and C<*FOO{FILEHANDLE}> is a reference to the filehandle C.
Notice how this is the only syntax available to create references
to filehandles.
As a special case, "THING" could also be one of C or C
to get at the actual name and package of a typeglob. This is useful
in situations where you need to identify precisely what kind of
typeglob you have on your hands. For example:
package Wierd;
@foo = (1,2,3);
my $buz = *foo;
package main;
print *{$buz}{NAME}, "\n";
print *{$buz}{PACKAGE}, "\n";
__END__
foo
Wierd
Notice the result is a plain string (not a reference, as for basic
types).
This syntax is intended to be perl's extensible mechanism to refer
to some of the current basic types like FILEHANDLE, and other more
exotic ones that may get added in future, without having to
resort to the use of more of those endangered prefix characters.
Is that sufficient?
- Sarathy.
gsar@engin.umich.edu