my %hash_of_hashes; while () { my @unitfiles_field = split /,/; # this is just an autogen number my $record = $unitfiles_field[0]; my %unitfiles_hash = ( lastname => $unitfiles_field[1], firstname => $unitfiles_field[2], DOB => $unitfiles_field[7], funding => $unitfiles_field[18], URNo => $unitfiles_field[15], Photo_permission => $unitfiles_field[14], ); # add this hash to the hash-of-hashes: $hash_of_hashes{$record_no} = \%unitfiles_hash; }