my %dispatch = ( 1 => \&show_installed, 2 => \&show_available, 3 => \&rgetpkglist, ... } $dispatch{$sel}->();