CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate: Re: [wyndcrosser] Finding data in arrays: Edit Log

Veteran / Moderator

Oct 8, 2012, 4:07 AM

Views: 7158
Re: [wyndcrosser] Finding data in arrays

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.

For example:

my %students = ( 
123 => {
First_Name => 'Bill',
Last_Name => 'Smith',
Amount_Due => 100,
321 => {
First_Name => 'John',
Last_Name => 'Doe',
Amount_Due => 50,

Basic skeleton of script operation:

while (1) { 
# display menu and retrieve user input
# lookup user input in the hash
# execute the subroutine based on hash lookup of user's input

(This post was edited by FishMonger on Oct 8, 2012, 4:17 AM)

Edit Log:
Post edited by FishMonger (Veteran) on Oct 8, 2012, 4:17 AM

Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives