|more useful options|
Re: getting at the text of an iconby wog (Curate)
|on Dec 13, 2001 at 08:16 UTC||Need Help??|
Short answer: you can't do that; you shouldn't be doing that.
Long answer: you can do it, sometimes; but it's not really a good idea.
For variables in the symbol table, you can find this information, by recursing through the symbol table, with something like this (this example only works on scalars, extending it should be relatively simple, see also perlref):
This function will find all variables with a certain values in the symbol table, by comparing the "SCALAR(0xDEADBEEF)"-like strings you get when you stringify references. (See also perlref). Note that I say all; there can be multiple copies of a variable in the symbol table when Exporter or the *glob = \$variable or *glob1 = *glob2 syntaxes are used. (This function returns the variable names from the prespective of the main package, since that's where it starts searching from, and I didn't want to have all the results have :: or main:: on the front.)
However, this all won't work for my'd variables, which are generally preferred in perl code. You could probably do my'd variables with some C code, but I wouldn't count on it not breaking in future versions of perl. (There is nothing in the public API to do that.)
Using variables as variable names is, in general, a very bad idea. See this set of articles. So, please, don't do that. You can, with a few rare exceptions, always use (possibly nested) data structures instead of variables as variable names.
update: I realize (impossiblerobot's very closely spaced post reminded me) I didn't emphasize enough that this is going to inefficient. Searching through the symbol table is that way, and that's another reason why it's best left avoided.