> For historic reasons,
Sorry, which historic reasons?
If you don't like caller's interface - where I sympathize - I'd rather propose something more flexible like returning a hashref:
DB<116> sub __CALLER__ {
my $level = shift;
my %hash;
@hash{qw/package filename line subroutine hasargs wantarray
+ evaltext is_require hints bitmask hinthash/} = caller($level+1);
return \%hash
}
DB<130> sub tst { print __CALLER__->{subroutine} }
DB<131> tst()
main::tst
or
DB<136> use Data::Dump qw/dd/
DB<137> sub tst { dd __CALLER__ }
DB<138> tst()
{
bitmask => "\0\0\0\0\0\0\0\0\0\0\0\0",
evaltext => undef,
filename => "(eval 108)[multi_perl5db.pl:644]",
hasargs => 1,
hinthash => undef,
hints => 256,
is_require => undef,
line => 2,
"package" => "main",
subroutine => "main::tst",
"wantarray" => 1,
}
Though not sure about using this underscore __NAMESPACE__...
And I'm pretty sure about reinventing the wheel ...
... CPAN is so big and I'm so lazy ;-)
Cheers Rolf
( addicted to the Perl Programming Language)
|