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:

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
Here is my current code for the program:
#!/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; }
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.


In reply to Returning and passing data to and from subroutines by vendion

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.