in reply to Order a hash?
You could iterate over the single lines of what the database returns (at least using DBI 1.12, don't know about pre-1.0-versions), therefore preserving the order generated by the database (your "order by" statement):
8-)... $dbh = DBI->connect("DBI:mysql:$database:$hostname", $user, $password) +; $statement = "select ... order by ..."; $sth = $dbh->prepare($statement) or die "Can't prepare $statement: $dbh->errstr\n"; $rv = $sth->execute or die "can't execute the query: $sth->errstr\n"; my @row; while(@row = $sth->fetchrow_array) { # @row contains the individual columns # ... do work ... } $rc = $sth->finish; $rc = $dbh->disconnect;
Andreas
|
|---|