Hi all! i wrote this code and now i want to convert my matrix into and array of arrays so that will be easear for me to work with.. do you have any suggestions?
while (my $key1 = shift @keys) { ##enters loop 2 alignments at the t +ime foreach my $key2 (@keys) { $seq1 =$sequences->{$key1}; $seq2 =$sequences->{$key2}; LINE: for (my $i=0; $i< length $seq1; $i++){ my ($substr1,$substr2) = (substr($seq1,$i,1),substr($seq2, $i, +1)); next LINE if ("$substr1$substr2" =~ /-/); if("$substr1$substr2"=~ /[^@aminos]/){ $else->{$substr1}->{$substr2}+=1; $else->{$substr2}->{$substr1}+=1; next LINE; } if ($substr1 eq $substr2){ $matrix->{$substr1}->{$substr2}++; $eq->{$substr1}++; }elsif ($substr1 ne $substr2){ $matrix->{$substr1}->{$substr2} += 1/2; $matrix->{$substr2}->{$substr1} += 1/2; } } } } print " A C D E F G H I K L M N + P Q R S T V W Y\n\n"; foreach my $key (sort keys %$matrix){ print $key." "x2; foreach my $key2 (sort keys %{$matrix->{$key}}){ printf("%3d ", $matrix->{$key}->{$key2}); } print "\n"x2; }

In reply to converting a hash based matrix into an array based matrix by madM

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.