while (my $row = $sth->fetch_arrayref()) { ... } #### my $rows = $sth->fetchall_arrayref(); my $num_rows = @$rows; foreach my $row (@$rows) { ... } #### my $rows = $sth->fetchall_arrayref(); my $num_rows = @$rows; my $sponge = DBI->connect('dbi:Sponge:'); my $sponge_sth = $sponge->prepare( $sth->{Statement}, { rows => $rows, NAME => $sth->{NAME}, behave_like => $sth, } ); while (my $row = $sponge_sth->fetch_arrayref()) { ... }