sub main_menu($$){ --code to handle main } sub other_menu($$){ --code } my %dispach_sub =( main_menu=>\&main_menu , other_menu=>\&other_menu ); ..after reading the data file into $var, $dispach_sub($var)($screenpos1, $screenpos2); ...