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.
In reply to Re^2: Saving/recovering sub refs in a file
by madscientist
in thread Saving/recovering sub refs in a file
by madscientist
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |