use strict; use Data::Dumper; my @fields = qw(cust_id ssn relation); my @ent = ("A1", "C1", "S1"); my @id = ("007", "008", "005"); my @ssn = ("999-99-9999", "888-88-8888", "777-77-7777"); my @rel = ("self", "spouse", "son"); my %data; for my $i (0..$#ent) { my %hash; @hash{@fields} = ($id[$i],$ssn[$i],$rel[$i]); $data{$ent[$i]} = \%hash; } print Dumper \%data;