sfink has asked for the wisdom of the Perl Monks concerning the following question:
So I am figuring out the name of the variable by scanning through the package's symbol table to find the reference to the variable that was passed to MODIFY_SCALAR_ATTRIBUTES. (I do the scan much later than the MODIFY_SCALAR_ATTRIBUTES is called, which is probably good because I'm not sure if the variable has been added to the symbol table back then.) It's working fine, but I'm wondering what sort of gotchas to watch out for. Obviously lexical variables won't work, but that's not a problem for me since for other reasons it makes much more sense for these variables to be 'our' variables anyway. If someone deleted my variable from the symbol table, could the reference be reused (I mean, the memory address that the reference was in)? I don't think so, because I have to keep the reference around in order to look it up in the symbol table. What would happen if after the variable declration, I 'use'd a module that exported that variable?
Or, even better, is there a more direct way of figuring out an attributed variable's name? It need not be fast, but it must be robust.
|
|---|