LANTI has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks,
for a debugging-sub I would like to pass the name of a variable to the sub. How is this possible?
What I have so far (untested yet):
say sdump($some_ref); sub sdump { my $ref = shift || croak('nothing to dump - missing ref'); my $depth = shift || 2; local $Data::Dumper::Maxdepth = $depth; return 'Dump of $var_name: ' . "\n" . Dumper($ref) }
How can I get the $var_name('$some_ref' in this exemple) into the sub?
Back to
Seekers of Perl Wisdom