in reply to How to extract the name of a variable?

If this is for tracing variables/values for debugging purposes, take a look at Smart::Comments. It's a source filter, but when you turn debugging off for production use, you do it by commenting out the use line, so there is no source filter used in the production code.

To trace a variable by name, you simply place the name of the var in a comment and when you use S::C, it will trace the name and value of the variable to STDERR.

c:>perl -MSmart::Comments $var = 123; ### $var $x = 'fred'; ### $x ^Z ### $var: 123 ### $x: 'fred'

It does a lot more besides.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.