package Options; use Exporter::Dispatch; sub main_menu { ... } sub other_menu { ... } #### my $var = ...; my %dispatch_sub = create_dptable Options; $dispatch_sub{$var}->($screenpos1, $screenpos2) if exists $dispatch_sub{$var};