} elsif ( $option == 8 ) { return(0); ######change here } else { print "Error: Option $option invalid\n"; ; main(); print "leftover\n"; ###change here ; } #### #!/usr/bin/perl -w use strict; while (display_menu(), (my $option = ) ) { $option =~ s/^\s*//; #no leading whitespace $option =~ s/\s*$//; #no trailing whitespace #(no need for chomp) as \r\n\t\f #and space all count as \s chars if ( ($option !~ /^\d$/) or ($option <=0) or ($option >2) ) { display_menu_error ("ERROR: illegal option: $option selected\n"); next; } print "opt number is $option\n"; #just a debug statement action1() if $option == 1; action2() if $option == 2; #etc..... #note: this compare is so fast, that no need to clutter things #up with elseif statements } sub action1 { clear_screen(); print "OPERATION 1 ok: \n"; #could be an error message } sub action2 { clear_screen(); print "did action 2\n"; } sub clear_screen { if ( $^O =~ /MSWin32/ ) { system('cls'); } else { system('clear'); } } sub display_menu_error { my $msg = shift; clear_screen(); print "$msg\n"; } sub display_menu { print "Cleveland State CC Computer Repairs\n\n"; print "Version xxxxxxx\n", "Copyleft 2009 Adam Jimerson & Andy Arp\n"; print "----------------------------\n", "Main Menu, To make a selection specify the number for that action\n"; print "1. Add New Computer to Database\n"; print "2. Edit Computer Status in Database\n"; print "3. Remove a Computer from Database\n"; print "4. Look up Computer Information\n"; print "5. List All Repair Requests\n"; print "6. Print Final Report For Customer\n"; #this should be done to ensure we provide information on a repair #to the customer on paper print "7. Check Computer Status\n"; print "8. Quit the program\n"; print "Action: "; }