my %hash_of_hashes = ( my $record_no => my %unitfiles_hash ); #suck all the unit files into a big hash to make searching easier while () { my @unitfiles_field = split /,/; #this is just an autogen number $record = $unitfiles_field[0]; %hash_of_hashes{$record_no} = ( %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], ); ); } #end while