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

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

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



FishMonger
Veteran / Moderator

Oct 8, 2012, 4:07 AM


Views: 2982
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:

Code
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:

Code
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