#!/usr/bin/perl use strict; use warnings; use version; my $VERSION = qw('2.0.0_3'); use English qw( -no_match_vars ); while ( display_menu(), ( my $option = <> ) ) { $option = data_verify($option); if ( ( $option !~ m{/^\d$/}xms ) or ( $option <= 0 ) or ( $option > 10 ) ) { display_menu_error("ERROR: illegal option: $option selected\n"); next; } if ( $option == 10 ) { $dbh->disconnect; print "Quitter...\n"; exit 0; } } sub clear_screen { # Clears the screen for both Windows and *nix systems and returns to the caller if ( $^O =~ /MSWin32/ ) { system 'cls'; } else { system 'clear'; } return; } sub display_menu { # Displays the main menu #db_connect(); #Commented out for debugging my $menu = <<"END_MENU"; Cleveland State CC Computer Repairs Version $VERSION, Copyleft 2009-2010 Adam Jimerson & Andy Arp ---------------------------- Main Menu, To make a selection specify the number for that action 1. Add New Computer to Database 2. Edit Computer Status in Database 3. Remove a Computer from Database 4. Look up Computer Information 5. List All Repair Requests 6. Customer Checkout 7. Check Computer Status 8. Add a Comment 9. Add a Donation Amount 10. Quit Action: END_MENU print $menu; return; } sub data_verify { # takes in information and loops through testing the input for valid alphanumeric characters. my @data = shift; my $loop_count = 0; while (@data) { $data[$loop_count] =~ m{s/^\s*//}xms; $data[$loop_count] =~ m{s/\s*$//}xms; $loop_count++; } return @data; }