my %dispatch = ( foo => sub {}, bar => sub {}, baz => sub {}, qux => sub {}, ); if( exists $dispatch{ $method } ) { $dispatch{$method}->(); } );