# keys %foo: extracts the keys from hash %foo # and returns them as an array # # sort @foo: sorts the elements of array @foo # # foreach: loops through the my @aKeys = sort(keys(%hSequences)); foreach my $k (@aKeys) { my $v = $hSequences{$k}; #get value $k =~ s/ / gid=/; print ">$k\n" . join("\n", sort @$v) . "\n"; }