#! perl use strict; use warnings; use Data::Dump; my %nodemetrics; my @nodelist = qw(server1 server2); my @attributes = qw(memory cpu disk network); my $string = '1024|2200|30|100'; my @data = split /\|/, $string; @{ $nodemetrics{$_ } }{@attributes} = (0) x @attributes for @nodelist; dd \%nodemetrics; @{ $nodemetrics{server1} }{@attributes} = @data; dd \%nodemetrics;