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.
|
|---|