In that case the hash of hash is exactly appropriate and it looks like my sample code should drop right into your application. Happy to help.
Update: there is enough information to generate the header too: ;)
... my @species = sort keys %data; my $nSpecies = @species; # Print the header print "begin data;\n"; printf "dimensions ntax=%d nchar=%d;\n", $nSpecies, $dnaLen + $morphLe +n; printf "format datatype=mixed (dna:1-%d, standard:%d-%d) missing=? ga +p=-;\n", $dnaLen, $dnaLen + 1, $dnaLen + $morphLen; print "Matrix\n"; # Print the data for my $species (sort keys %data) { $data{$species}{dna} ||= '?' x $dnaLen; $data{$species}{morph} ||= '?' x $morphLen; print "$species: $data{$species}{dna}$data{$species}{morph}\n"; } print "end;\n";
Prints:
begin data; dimensions ntax=5 nchar=32; format datatype=mixed (dna:1-14, standard:15-32) missing=? gap=-; Matrix species_1: ACCATGATACGATG001001010201001001 species_2: GGTTTCGACGCAGA002010200210120201 species_3: GGACTCAGCGACTA?????????????????? species_4: ??????????????001001110000000101 species_5: ??????????????111001001001000201 end;
In reply to Re^3: Combining hashes of hahses?
by GrandFather
in thread Combining hashes of hahses?
by erio
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |