for my $signature (keys %hash) { my $structure = $hash{$signature}; printf "%s|%s\n%s\n%s\n", $structure->{id1}, $structure->{id2}, $structure->{sequence}, $structure->{label}; }