sub caller_info { my $i = shift(@_) + 1; my %call_info; { package DB; @args = \$i; # A sentinal, which no-one else has the address of @call_info{ qw(pack file line sub has_args wantarray evaltext is_require) } = defined &{"CORE::GLOBAL::caller"} ? &{"CORE::GLOBAL::caller"}($i) : caller($i); } unless (defined $call_info{pack}) { return (); } my $sub_name = Carp::get_subname(\%call_info); if ($call_info{has_args}) { my @args; if (@DB::args == 1 && ref $DB::args[0] eq ref \$i && $DB::args[0] == \$i) { @DB::args = (); # Don't let anyone see the address of $i @args = "** Incomplete caller override detected; \@DB::args were not set **"; } else { @args = map {Carp::format_arg($_)} @DB::args; } if ($MaxArgNums and @args > $MaxArgNums) { # More than we want to show? $#args = $MaxArgNums; push @args, '...'; } # Push the args onto the subroutine $sub_name .= '(' . join (', ', @args) . ')'; } $call_info{sub_name} = $sub_name; return wantarray() ? %call_info : \%call_info; }