This:
for ($a=0; $a<=$#columns; $a++) { for ($b=0; $b<=$#columns; $b++) { print "$list[$a][$b] "; # for testing } print " \n"; }
should probably avoid using the $a and $b variables, which have a special purpose (for sorting).

In general, you should probably try to avoid using the C-style for loop and array subscripts when you can, because it can be made significantly simpler and easier by iterating directly over the values (no off-by-one errors, no out-of-range errors).

my @AoA = ([1, 2, 3], [4, 5, 6], [7, 8, 9]); # an array of arrays for +testing purpose for my $row (@AoA) { for my $col (@$row) { print "$col "; } print "\n"; }
which prints:
1 2 3 4 5 6 7 8 9

And if you need to make some calculations:

my @AoA = ([1, 2, 3], [4, 5, 6], [7, 8, 9]); for my $row (@AoA) { my ($sum, $count) = (0, 0); for my $col (@$row) { $sum += "$col "; $count ++; } print "Average: ", $sum / $count, "\n" if $count; }
which will print the three computed averages:
Average: 2 Average: 5 Average: 8
Update: The comment about $a and $b was made earlier by zentara, but below in this thread, I had not noticed it when I mentioned that.

In reply to Re^7: reading files in @ARGV doesn't return expected output by Laurent_R
in thread reading files in @ARGV doesn't return expected output by fasoli

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.