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