"1" => \&get_ifc_name({'ifc_default' => 'test_me',}), #### "1" => \&get_ifc_name, #### #!/usr/bin/perl use warnings; print "************************************\n"; print "* test - shift9999\n"; print "* Version 0.1 - \"The mule\"\n"; print "************************************\n"; print "\n"; #Define args my($ifc_name); my($ipaddress); #run the menu_system for the first time. &menu_system; sub menu_system($bs_index){ #Define our menu system here with the appropriate subs and their arguments my %menu_hash = ( "1" => \&get_ifc_name({'ifc_default' => 'test_me',}), "2" => \&get_ip_address, ); #first run check to setup the first menu if(!$bs_index) { #start things off at the first menu $bs_index = "1"; } else { #Get menuid from Arg - Don't mind this, never removed the unnecessary. my($temp_hld) = @_; $bs_index = $temp_hld; } #check to see if the menu index is defined, otherwise display an error. if (defined $menu_hash{$bs_index}) { #menu is valid, run the sub $menu_hash{$bs_index}->(); } else { print "***Menu System Error***\n"; } } sub get_ifc_name{ #get hashref from args my ($inp) = @_; #prompt user for input print "Enter the Public Interface: [ \"$inp->{'ifc_default'}\" ]\n"; $ifc_name = ; chomp($ifc_name); #if no input use default value from the arguments passed to this sub if (!$ifc_name) { print "Using Deafult Interface: [ \"$inp->{'ifc_default'}\" ]\n\n"; $ifc_name = $inp->{'ifc_default'}; #call the next menu &menu_system("2"); } else { #*** will push these checks into a reusable sub later but for now just take care of it here. #check if the user wants to go back or restart the section. if($ifc_name =~ /back/){ print "\n***Cannot go back any further***\n\n"; &menu_system("1"); } elsif ($ifc_name =~ /skip/){ print "\n***Cannot skip this step***\n\n"; &menu_system("1"); } else { # user entered a valid name, lets use that instead of the default. print "Using Device Name: [ \"$ifc_name\" ]\n\n"; &menu_system("2"); } } } sub get_ip_address{ #get ip address print "IP Address for: [ \"192.168.6.100\" ]\n"; $ipaddress = ; chomp($ipaddress); } exit;