Phoenix.pm: Symbol Tables part deu
Beaves at aol.com
Beaves at aol.com
Mon Oct 4 11:59:06 CDT 1999
Thanks for the two code examples.
But the only problem that I can see is if there were also a variable of the
same name, then this would also test positive. So, more specifically, can I
test to see if the {CODE} portion of the symbol table is filled for a
specific name?
This problem occurs in a package I'm building. Here, you cannot necessarily
guarantee that the user of your package is smart enough to not use the same
name for both a subroutine and something else. Of course, that could be a
stiplulation in the documentation, but I thought I'd be able to get around
that with some fancy knowledge of the tables.
So, let's say if you wrote:
$load_email = 1; # perhaps a flag
but NEVER wrote:
sub load_email { return 1 }
The code examples in the replies would still return true, because the name
exists in the table, but its the {SCALAR} portion of the symbol table hash
that is filled, not the {CODE} portion. Does this make sense so far?
This may be a stupid and minor 'problem' with other workarounds, but I feel
that if I work around it, then I may be missing a major concept as to the
inner workings of Perl.
Thanks,
Tim
(P.S. As a further brain teaser: I know you can delete a symbol from the
symbol table, as you can with any other hash. But can you delete just the
{CODE} portion of the symbol table of a particular name? But of course, if
the first dillemma is figured out, then this will probably be answered at the
same time...)
More information about the Phoenix-pm
mailing list