in reply to Log4perl, Data::Dumper and varname

Dumping variables but DRY and simple, How to extract the name of a variable?

Replies are listed 'Best First'.
Re^2: Log4perl, Data::Dumper and varname
by josh803316 (Beadle) on Apr 09, 2010 at 06:09 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).

        Here is the solution which seems to work for me:

        $logger->trace( sub { Data::Dumper->Dump($name, 'name') }, undef, $TRACE, undef, undef );