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: [Laurent_R] Finding data in arrays: Edit Log



wyndcrosser
Novice

Oct 9, 2012, 6:47 PM


Views: 2777
Re: [Laurent_R] Finding data in arrays

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;
}
}

#if number is found, display the information for that array number.
if ($i>=0)
{
print "\nStudent ID: \t@studentID[$i]";
print "First Name: \t@firstName[$i]";
print "Last Name: \t@lastName[$i]";
printf ("Amount Due: \t\$%1.2f", @amountDue[$i]);
}

#if not found, print name not found
else
{
print "\nName not found.\n";
}

Perl Newbie - 7 months of PERL basics.

(This post was edited by wyndcrosser on Oct 9, 2012, 7:34 PM)


Edit Log:
Post edited by wyndcrosser (Novice) on Oct 9, 2012, 7:34 PM


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

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