I don't know how far you want to go to get the names but this seems to work well in my limited testing.
Foo.pm:foo.pl:package Foo; use strict; use warnings; use Sub::Name; # forward declarations so AUTOLOAD can limit what works use subs qw( func funk ); $\ = "\n"; sub show { print join "\t", (caller(0))[0..3]; } sub AUTOLOAD { my ( $name ) = our $AUTOLOAD =~ /::(\w+)$/; return unless __PACKAGE__->can( $name ); # only allow those subs l +isted above my $fullname = __PACKAGE__ . '::' . $name; no strict 'refs'; *{ $fullname } = Sub::Name::subname $fullname => *show; goto &$fullname; } 1;
#!/bin/env perl use strict; use warnings; use Foo(); Foo::show(); Foo::func(); Foo::funk();
Output:
main ./foo.pl 7 Foo::show main ./foo.pl 8 Foo::func main ./foo.pl 9 Foo::funk
In reply to Re: Name of caller if aliased?
by Mr. Muskrat
in thread Name of caller if aliased?
by LanX
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |