##
my @data;
foreach (keys %hash) {
push @data, do_something_with($hash{$_})
if scalar @{$hash{$_}} > 0;
}
####
my @elems = qw(foo bar baz quux ichi ni san shi go roku hachi);
my $set = 3;
while(scalar @elems) {
do_something_with(splice(@elems, 0, $set));
}