Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Find odd/even elements of array

by choroba (Abbot)
on Oct 09, 2011 at 21:44 UTC ( #930501=note: print w/ replies, xml ) Need Help??


in reply to Find odd/even elements of array

You might use array of arrays for you data:

push @studentInfo, [@row];
Then, $studentInfo[$x][0] contains the ID and $studentIfno[$x][1] the name. If the IDs are uniqe, you may profit from Perl's hashes, so build your structure in a different way:
my %studentInfo; while (my @row = $sth_queryID->fetchrow){ $studentInfo{$row[0]} = $row[1]; }
In this case, $studentInfo{$id} contains the name (and should be renamed to %id_to_name or similar).
Update: see perldsc for details.


Comment on Re: Find odd/even elements of array
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://930501]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (6)
As of 2014-07-30 00:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (229 votes), past polls