my @sorted = ('A'..'Z'); # probably sort keys %some_hash; reduce(@sorted); sub reduce { my @ten = splice(@_, 0, 10); return if (!@ten); # Base case # return if (@ten < 10); # Or do you want to stop if < 10 elements? print join(',',@ten) . "\n"; return reduce(@_); # Recursion case, remainder of array }