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:
%query=('action1'=>\&handler1, 'action2'=>\&handler2, 'action3'=>\&_do_not_advertise_this_function_externally, # and so on );
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]
|
|---|