vendion has asked for the wisdom of the Perl Monks concerning the following question:
Hello all I'm trying to develop an in house ticket system for a student lead non-profit computer repair service at my college. I'm currently running into two major problems, don't know if they are related or not, which causes this program to be unusable.
The first problem happens when the program should check the input from the user. This process errors out with the following error Use of uninitialized value within @data in pattern match (m//) at repairs.pl line 212, <> line 1. When I comment out line 212 and 213 then the program just hangs. Here is a more details of what gets printed out:
Here is my current code for the program:Cleveland State CC Computer Repairs Version '2.0.0_3', 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: 10 Use of uninitialized value within @data in pattern match (m//) at repa +irs.pl line 212, <> line 1. Use of uninitialized value in pattern match (m//) at repairs.pl line 2 +13, <> line 1.^C
If for any reason anyone needs all of my code you can get it from vendion's scratchpad or from http://pastebin.org/385645 I thank you in advance for any help offered, and for any other suggestions.#!/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 > 1 +0 ) ) { 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 a +lphanumeric 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; }
|
|---|