Do you actually require splitting the hash? Partitioning the keys might suffice in many situations.
In any case, using part is one option.
Update. Much cleaner with key/value slices[*] (untested):use List::MoreUtils qw(part); use constant NWAYS => 3; my $i; #my @AoA = part { $i++ % NWAYS } keys %hash; my @AoH = map +{map {$_ => $hash{$_}} @$_}, part { $i++ % NWAYS } keys + %hash;
use 5.020; my @AoH = map +{ %hash{@$_} }, part { $i++ % NWAYS } keys %hash;
In reply to Re: How can I split a hash into other N hashes
by oiskuu
in thread How can I split a hash into other N hashes
by ataX
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |