use Dumpvalue; %id_lookup_table = map { ($Merged_Ids[$_], $merged_array[$_]) } 0..$#Merged_Ids; my $dumper = Dumpvalue -> new; $dumper -> dumpValue(\%id_lookup_table); open(ERRORREPORT,"+<","reported_list.csv") or die "reported_list.csv: $!"; print ERRORREPORT @id_lookup_table{(@sample_ids)}; close ERRORREPORT; 'UCD12-00242-P' => "\"Joe Schmie\",ABD032,12-Feb-12,23-Feb-12,\"Whale Tail Island, Fictitious Place\",USA,California,etc