in reply to loop though query results twice

execute it again, or save the results from the first pass.
my @rows; while (my $row = $sth->fetch()) { push @rows, [ @$row ]; ... } for my $row (@rows) { ... }

[ Me bad. I pretty much only read the title ]