good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
How do I determine if a variable contains a type glob A variable never contains a type glob. It either is a typeglob by itself - in that case the the string following the sigil can be looked up in the package's symbol table - or it contains a reference to a part of a typeglob (a typeglob slot entry container). In the latter case the reference carried inside the variable is identical to the contents of a certain typeglobs slot entry inside the symbol table. A none-typeglob (not package) variable never contains or is a type glob, all it can do is sharing the typeglob's reference for a certain type. Consider:
Note how *{"main::foo"}{SCALAR} and $baz and $quux all share the same reference, despite being different variables. So, if you want to determine whether a variable contains part of a typeglob, iterate over the keys of the current packages symbol table, and for each symbol, iterate over the typeglobs reference entries, and if those are equal to the variable's content, it shares some part(s) of a typeglob's values. That's all you can get.
perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'
In reply to Re: How do I determine if a variable contains a type glob?
by shmem
|
|