I have finished all of my assignments for this semester, but this one. I'm way ahead in class, but arrays are not my thing... The following code is what I'm attempting to do. There are no comments yet, as I haven't gotten my code down 100%

There is a menu with three options. 1 is print out the amount of all students owed (sum of @amountDue).

Option 2 is ask for a student ID, if the ID is found print out the name, amount owed, and if the ID isn't found create data in the array with name,amount owed and studentID. Press "0" to back out option 2 menu and return to the main menu (options 1-3).

**option two is where I'm stuck**

Option 3 terminates the program.

I have tried numerous ways such as if statements for if ($temp ~~ @studentID) do blank. This works, but then I can't hit "0" to back out of the program. I have also tried using GREP to validate if data is present in the array. You'll see where $choice == 2 is where I'm having the difficulties at, I have grep there now, I was attempting to debug it. I'm guessing I'm going to need to use a for loop to validate the information in the array and pull from it.

Any support on this, or clarifications for identifying how to look into an array and print out information, would be greatly appreciated.

Also note down where is says "} while ($temp eq 0); "

I initially had until ($temp == 0); I was looking at ways to see why 0 wouldn't bring me back to the main menu.

Code erased.

if someone else if having issues with a similar project you can msg me there and ask. Perl Newbie - 7 months of PERL basics.

Since this is for a course homework assignment, I can't/won't give you the code, but I can/will give you some guidance.

There are several ways to approach this problem, but IMO, the best approach would be to use a dispatch table. A dispatch table is a hash where the keys are the menu options and the value of each of them point to a code reference, (i.e., a reference to a subroutine that is executed when that option is entered).

You need 4 subroutines for the dispatch table. One for each menu option and one "default" to handle invalid input.

After prompting/accepting the user's selection, you sanitize it as needed and compare it against the hash keys and execute the appropriate subroutine.

I'm not going to provide the actual code or reference links, because finding that out is part of your task in completing the assignment.

If/when you get stuck, you can post specific questions along with your code and we will help where we can, without doing your homework for you.

My hardest issue is verifying how to correctly find the data in studentID and identify what the if statement should do? Does there need to be a loop there?

I'm not asking for "here's some code", but just some clarification, or if someone is willing to guide me through what I'm asking. I don't plan on being a PERL expert, but I would like to figure out what the heck I'm doing :).

This is a basic PERL class, so I'd like to stay in the realm of that thinking as well :).

Is using arrays a requirement for the assignment? Using separate arrays is a really odd choice of data structure for this task. Instead, you should be using a hash (more specifically, a Hash of Hashes) where the key is the student ID and the value is a hash reference containing the rest of the data.

I have no clue what you guys are talking about, but this is how i ended up doing it. I'll erase the code from here soon so ppl can't copy it.

Code

#for loop to support looking into the array from the last entry for ($i=$#studentID; $i>=0; $i--) { #pulls from the for loop looking for the search_key id within the studentID array if ($studentID[$i] == $search_key) { #exits the loop last; } }