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