josh803316 has asked for the wisdom of the Perl Monks concerning the following question:

I often use Data::Dumper like this:
warn Data::Dumper->Dump([$p],['p']);
# Which will dump with the variable p = {} instead of $VAR1 = {}

Sometimes I use log4perl and Data::Dumper like this (from the log4perl faq)
$logger->trace( {filter => \&Data::Dumper::Dumper, value => $variable_ +to_dump }, undef, $TRACE, undef, undef );
So my question is, how can I dump the value so it looks like $variable_to_dump instead of $VAR1?

Replies are listed 'Best First'.
Re: Log4perl, Data::Dumper and varname
by Anonymous Monk on Apr 09, 2010 at 02:27 UTC
      I looked through both of those posts but wasn't sure how I could use the information to dump the $logger variable with a different name then $VAR1. Sorry if I'm being obtuse but I just couldn't connect the dots...
        I looked through both of those posts but wasn't sure how I could use the information to dump the $logger variable with a different name then $VAR1.

        There is only about 3 direct replies with actual code. Pick one and test (I'd go for the one which references Data::Dumper the most).