hmh ... seems not to work, if the dumped ref is a lexical variable in production-code. For the moment I live with this solution - not very elegant, because most of the time the identifying string will be same as the var-name:
say sdump($pout, '$pout');
sub sdump {
my $ref = shift || croak('nothing to dump - missing ref');
my $name = shift || 'n/a';
my $depth = shift || 2;
local $Data::Dumper::Maxdepth = $depth;
return "Dump of $name:\n" . Dumper($ref);
}
Any idea, how to call it this way?
sdump('$pout');