in reply to Re: Saving/recovering sub refs in a file
in thread Saving/recovering sub refs in a file

You can get the subroutine source from a reference using B::Deparse.

Hm. That's interesting. What I was really looking for was a way to find the string name of a sub, not the source for it. IOW, suppose I had:

package my::Plugins::SomePlugin; sub myhandler { do_something(); } my::Error::register(\&myhandler);
Then inside my::Error::register() somehow I could convert the ref I'd been passed back into the name of the sub (in this case the string "my::Plugins::SomePlugin::myhandler").

Replies are listed 'Best First'.
Re^3: Saving/recovering sub refs in a file
by Khen1950fx (Canon) on Jun 16, 2010 at 23:18 UTC
    I would do it this way:
    package My::Plugins::SomePlugin; use strict; use warnings; use Sub::Identify ':all'; sub name { my $subname = sub_name(\&myhandler); defined $subname and print "$subname\n"; } sub myhandler { do_something(); } My::Plugins::SomePlugin::name;