package dispatch; sub foo {} sub bar {} sub baz {} sub qux {} package main; if( my $ref = dispatch->can($method) ) { $ref->(); }