I have a hash of arrays.
%HoA = ( 'C1' => ['1', '3', '3', '3'], 'C2' => ['3','2'], 'C3' => ['1','3','3','4','5','5'], 'C4' => ['3','3','4'], 'C5' => ['1'], );
I would like to write a subroutine that returns a hash of the โsubcomponentโ of arrays that contains the first N keys (and their values) of the original hash of the arrays.
Something like that
my %HoA2 = new_partition(\%HoA, 3);
And it returns a new HoA data structure:
%HoA = ( 'C1' => ['1', '3', '3', '3'], 'C2' => ['3','2'], 'C3' => ['1','3','3','4','5','5'], );
Is there a way to do this from scratch without using a module?