Phoenix.pm: On another note
Shay Harding
mekla at geocities.com
Thu Jan 27 16:27:49 CST 2000
> print "TEMP exists\n\n" if exists $main::{TEMP}; # will print 'TEMP exists'
> # even though you havn't gotten to that line yet.
> $TEMP;
> delete $main::{TEMP};
> print "TEMP exists\n\n" if exists $main::{TEMP}; # will not print anything.
> $TEMP;
> print "TEMP exists\n\n" if exists $main::{TEMP}; # will not print anything.
> $TEMP=undef;
> print "TEMP exists\n\n" if exists $main::{TEMP}; # will print 'TEMP exists'
>
> I discovered this by accident when my little symbol table sub did not work as
> I was expecting.
I see what you were saying now. The above example made it much clearer. Thanks.
> Also, Shay, I didn't quite get the point of your code
> If you do:
>
> my $var = 9000;
>
> $var never gets a symbol table entry. So if I had some weird thing like:
>
> my $var = sub { return chr($_[0]) };
> print &$var(65), "\n\n";
>
> It seemed like you were missing a conclusionary sentence...
> That sub reference above seems like it would work OK, am I missing something?
>
> Tim
I thought the whole thing that started this was someone was trying to find if a
particular sub-routine existed by accessing the symbol table? In the above
instance the sub routine is anonymous and scoped via my so it has no symbol
table entry. It's referenced via a SCALAR so to see if an anonymous sub routine
was available would you have to look for the SCALAR which may not be there
depending on scoping.
Wish I could remember the whole purpose of finding the sub-routing in the first
place :) Maybe the above example had nothing to do with it?
Shay
More information about the Phoenix-pm
mailing list