Splice'n Slice!
use strict; use warnings; use integer; use Data::Dumper; my %hash = ( 1 => 'a', 2 => 'b', 3 => 'c', 4 => 'd' ); my $size = keys %hash; print "Total keys are $size.\n"; my $numSplit = 2; my $partSize = $size/$numSplit; my @keys = keys %hash; my @arrHash; while(my @keys2 = splice @keys, 0, $partSize ) { my %hash1; @hash1{@keys2} = @hash{@keys2}; push @arrHash, \%hash1; } print Dumper(\@arrHash);
In reply to Re: How to bucket an Hash
by hdb
in thread How to bucket an Hash
by techman2006
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |