- or download this
my %hash;
push @{$hash{$_}}, $_ for @elements;
...
# gets passed an array reference, deref if you so desire
do_something_with($hash{$_}) if scalar @{$hash{$_}} > 0;
}
- or download this
my @data;
foreach (keys %hash) {
push @data, do_something_with($hash{$_})
if scalar @{$hash{$_}} > 0;
}
- or download this
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));
}