in reply to Re: Saving/recovering sub refs in a file
in thread Saving/recovering sub refs in a file
Is there a way in my::Error::register() to "look up" the string and see if it's a real sub,(ref($s) // '') eq 'CODE'
Sorry, I wasn't clear. I'm familiar with ref(); that's not what I'm looking for (unless it has hidden properties I'm not aware of).
What I need to know is this: the caller will pass in a string naming a sub, and I want to know if the string corresponds to a real sub that has been defined, or not. In case the caller mistyped the name.
So for example, the caller runs: my::Error::register('my::Plugins::ThisPlugin::miHandler') but the name of the real sub is myHandler... is there any way inside the register() function that I can figure out if the string I've been passed is the name of a real, existing sub or not (without running it of course!)
I'd like to throw an error up-front in the register() function if someone passes a bad/invalid name for a sub, rather than waiting until a real error occurs and only finding out then, when someone tries to invoke the error handler, that it was bad.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Saving/recovering sub refs in a file
by ikegami (Patriarch) on Jun 16, 2010 at 18:27 UTC | |
by madscientist (Novice) on Jun 16, 2010 at 19:42 UTC | |
by ikegami (Patriarch) on Jun 16, 2010 at 20:38 UTC | |
by madscientist (Novice) on Jun 16, 2010 at 22:30 UTC | |
by ikegami (Patriarch) on Jun 16, 2010 at 22:49 UTC |