in reply to Re^3: Not sure how to populate a hash
in thread Not sure how to populate a hash

my @keys = keys %{$nodemetrics{'server1'}};
in a somewhat recent perl this leads to:
$ perl scratch.pl [...] 'server1' => { 'memory' => '1024', 'network' => '2200', 'cpu' => '30', 'disk' => '100' }, [...] $ perl scratch.pl [...] 'server1' => { 'disk' => '1024', 'memory' => '2200', 'cpu' => '30', 'network' => '100' } [...]

OUCH!!

You already have the keys in the correct order available, why not use that?

my @system_attributes = qw(memory cpu disk network); [...] my $hashref = $nodemetrics{'server1'}; @$hashref{@system_attributes}=@data;