Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Getting name of sub from a hash-based dispatch table?by theguvnor (Chaplain) |
on Jan 21, 2004 at 19:25 UTC ( [id://322968]=perlquestion: print w/replies, xml ) | Need Help?? |
theguvnor has asked for the wisdom of the Perl Monks concerning the following question: I've got a hash containing a dispatch table - the standard setup where labels are the keys and the subroutines are the values in the hash. Like so:
Question: how can I, prior to actually dispatching the call to the handler, find out the name of the subroutine that will be called? For instance for any given param $action, I would like to know whether I'll be going to a subroutine named with a leading '_' prior to calling $query{$action}->();. I don't want to resort to using symbolic refs and encoding the sub names as text strings in the values of my dispatch table - it seems wrong somehow. Is there an easier (or "better") way? [Jon]
Back to
Seekers of Perl Wisdom
|
|