Get variable name as string in Perl
- by Jose Cuervo
Hi, I am trying to get a text representation of a variable's name. For instance, this would be the function I am looking for:
$abc = '123';
$var_name = &get_var_name($abc); #returns '$abc'
I want this because I am trying to write a debug function that recursively outputs the contents of a passed variable, I want it to output the variable's name before hand so if I call this debug function 100 times in succession there will be no confusion as to which variable I am looking at in the output.
I have heard of Data::Dumper and am not a fan. If someone can tell me how to if it's possible get a string of a variable's name, that would be great.
Thanks!