Skip to content

Instantly share code, notes, and snippets.

@AndrewRussellHayes
Last active December 28, 2015 21:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndrewRussellHayes/7567187 to your computer and use it in GitHub Desktop.
Save AndrewRussellHayes/7567187 to your computer and use it in GitHub Desktop.
prints basic unix menu and handles input
sub menu{
manager::clearScreen();
my $menuText = "\n".$MENUPARTITION;
$menuText .= "\t MENU\n";
$menuText .= $MENUPARTITION;
$menuText .= " To Select an option, type\n it's number and press Enter.\n";
$menuText .= $MENUPARTITION;
$menuText .= " 1. Start Menu\n";
$menuText .= " 2. Stop Menu\n";
$menuText .= " 3. Change System Setting\n";
$menuText .= " 4. Back To Monitor\n";
$menuText .= "\n";
$menuText .= "\n";
$menuText .= "> ";
print $menuText;
my $selection = <>;
chomp($selection);
switch($selection){
case '1' { startMenu(); return; }
case '2' { stopMenu(); return; }
case '3' { settingsMenu(); return; }
case '4' { return; }
else { badSelection('menu()'); return; }
}
}
sub badSelection{
if($_[0]){ eval $_[0]; }
else{ menu(); }
return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment