in reply to Re: Call subroutine by reference ?
in thread Call subroutine by reference ?

Yes, and to clarify with-regard-to my previous post, there is no conflict between the two ideas ... they are quite-ordinarily used together, as Perl applications are quite-ordinarily built as systems of packages instead of monolithic and repetitive individual scripts.   If you use a package, the subs in them are (ordinarily ...) visible, both as subroutine_name and, if necessary, as package_name::subroutine_name.   You can build code-references freely, as shown, because everything comes-together in memory (just...) before execution of the whole thing begins.   The dispatch-table idea obviously is clearer and more-expandable than my if..elsif.. structure, which was merely used here for clarity.

n.b.:   In actual practice, the exists() function should be used to verify that the key being sought actually does exist in the table, before attempting the call.   e.g. die "horribly" unless exists($dispatch_table->{$key}); ... so that the program will react graciously, or at-least die on its own terms instead of puking with “can't use 'undef' as a code reference” or what-not.