ataX has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use strict; use warnings; $|++; use Data::Dumper; my $numOfHashes = 2; my $numOfHashesO = 2; my $worker; my $hashref = { '6712' => { 'IP_ADDRESS' => '1.2.3.44', 'IPV6' => '0', 'IP_ADDRESS_BIN' => '000000000000000000000000000 +000000000000', 'CSX_ID' => '6712' }, '6582' => { 'IP_ADDRESS' => '1.2.3.44', 'IPV6' => '0', 'IP_ADDRESS_BIN' => '000000000000000000000000000 +000000000000', 'CSX_ID' => '6582' }, '6282' => { 'IP_ADDRESS' => '1.2.3.44', 'IPV6' => '0', 'IP_ADDRESS_BIN' => '000000000000000000000000000 +000000000000', 'CSX_ID' => '6282' }, '6462' => { 'IP_ADDRESS' => '1.2.3.44', 'IPV6' => '0', 'IP_ADDRESS_BIN' => '000000000000000000000000000 +000000000000', 'CSX_ID' => '6462' }, '16712' => { 'IP_ADDRESS' => '1.2.3.44', 'IPV6' => '0', 'IP_ADDRESS_BIN' => '000000000000000000000000000 +000000000000', 'CSX_ID' => '6712' }, '26582' => { 'IP_ADDRESS' => '1.2.3.44', 'IPV6' => '0', 'IP_ADDRESS_BIN' => '000000000000000000000000000 +000000000000', 'CSX_ID' => '6582' }, '36282' => { 'IP_ADDRESS' => '1.2.3.44', 'IPV6' => '0', 'IP_ADDRESS_BIN' => '000000000000000000000000000 +000000000000', 'CSX_ID' => '6282' }, '46462' => { 'IP_ADDRESS' => '1.2.3.44', 'IPV6' => '0', 'IP_ADDRESS_BIN' => '000000000000000000000000000 +000000000000', 'CSX_ID' => '6462' }, '96182' => { 'IP_ADDRESS' => '9.0.0.0', 'IPV6' => '0', 'IP_ADDRESS_BIN' => '000000000000000000000000000 +000000000000', 'CSX_ID' => '6182' } }; my $keys = keys %{$hashref}; print "Original Hash Keys: $keys\n"; foreach my $key ( keys %{$hashref} ) { if ( $numOfHashes == 0 ) { $numOfHashes = $numOfHashesO; $worker->{$numOfHashes}->{WORK}->{$key} = $hashref->{$ +key}; } $worker->{$numOfHashes}->{WORK}->{$key} = $hashref->{$ +key}; $numOfHashes--; } foreach my $destKey ( keys %{$worker} ) { my $destKeyCount = keys %{$worker->{$numOfHashes}->{WORK}} +; print "$destKey: $destKeyCount\n" }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How can I split a hash into other N hashes
by kennethk (Abbot) on May 13, 2014 at 15:45 UTC | |
by ataX (Initiate) on May 13, 2014 at 16:51 UTC | |
|
Re: How can I split a hash into other N hashes
by GotToBTru (Prior) on May 13, 2014 at 16:12 UTC | |
by ataX (Initiate) on May 13, 2014 at 16:52 UTC | |
by GotToBTru (Prior) on May 13, 2014 at 17:36 UTC | |
|
Re: How can I split a hash into other N hashes
by oiskuu (Hermit) on May 13, 2014 at 17:47 UTC | |
|
Re: How can I split a hash into other N hashes
by Monk::Thomas (Friar) on May 13, 2014 at 17:06 UTC | |
|
Re: How can I split a hash into other N hashes
by kcott (Archbishop) on May 14, 2014 at 07:54 UTC | |
|
Re: How can I split a hash into other N hashes
by locked_user sundialsvc4 (Abbot) on May 14, 2014 at 01:35 UTC |