my $pos = 1; while ($hash = $sth->fetchrow_hashref()) { if ($pos > $skip) { push(@data, $hash); last if ($pos == ($skip+$slice)); } $pos++; }