in reply to hoh or hoa data structure
Show us some code. Ideally a trivial database using something like the following as a starting point:
#!/usr/bin/perl use strict; use warnings; use DBI; unlink 'results'; open my $resFile, '>', 'results'; print $resFile <<DATA; Joe,A,1,85,90 Joe,A,1,80,99 Joe,A,2,50,70 Joe,A,2,60,65 Joe,A,2,87,89 Joe,B,1,82,92 Joe,B,3,30,51 Rob,A,1,85,90 Rob,A,1,80,99 Rob,A,2,50,70 Rob,A,2,60,65 Rob,A,2,87,89 Rob,B,1,82,92 Rob,B,3,30,51 DATA close $resFile; my $dbh = DBI->connect("DBI:CSV:") or die $DBI::errstr; my $sth = $dbh->prepare("SELECT * FROM results"); $sth->execute(); my $arrayRef = $sth->fetchall_arrayref; print +(join ', ', @$_), "\n" for @$arrayRef; exit;
Prints:
Joe, A, 1, 80, 99 Joe, A, 2, 50, 70 Joe, A, 2, 60, 65 Joe, A, 2, 87, 89 Joe, B, 1, 82, 92 Joe, B, 3, 30, 51 Rob, A, 1, 85, 90 Rob, A, 1, 80, 99 Rob, A, 2, 50, 70 Rob, A, 2, 60, 65 Rob, A, 2, 87, 89 Rob, B, 1, 82, 92 Rob, B, 3, 30, 51
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: hoh or hoa data structure
by rocky13 (Acolyte) on Jan 10, 2011 at 23:39 UTC | |
by GrandFather (Saint) on Jan 11, 2011 at 00:46 UTC |