There is no order to keys of a hash array (unless you think that random == ordered ). If you want order, you can get it by using the NAME or NAME_lc attribute of the statement handle to get the order of selected columns, e.g.:
$sth->execute;
my @columns = @{ $sth->{NAME_lc} };
my %row; $sth->bind_columns(\@row{@columns});
while ($sth->fetch) {
for (@columns) {
print "$_ = $row{$_}\n";
}
}