First of all, please read the Writeup Formatting Tips - your post prior to editing was almost illegible and made your intent nearly impossible to discern. Now that we have covered that,

The Perl way of doing this would be a hash of hashes:
my %error_per_file; my %error_type; while(my ($filename, $errnum) = get_row_elements($some,$params,$here)) + { $error_type{$errnum}++; $error_per_file{$filename}->{$errnum}++; }

Substitute get_row_elements() with whatever delivers your colums. You then have all filenames as keys of the %error_per_file hash. The value will be a reference to a hash, whose keys in turn are the error numbers, and the values are the number of occurences of that error.

If all of that looks very strange, I suggest reading the perlreftut tutorial and perlref documentation to understand what's going on here.

Writing them back is a bit complicated:

my $column = 1; my %column_for = map ($_ => $column++), sort keys %error_type; $column_for{Filename} = 0;
Now we have a hash whose keys are column headers and whose values are the corresponding column numbers. $worksheet->write(0, $column_for{$col_name}, $col_name) for keys %column_for; Here we have put the elements in their corresponding columns, at row 0 of the worksheet. Finally, we populate the rest of the rows, one at a time:
my $row = 1; for my $filename (sort keys %error_per_file){ $worksheet->write($row, 0, $filename) my ($errnum, $occurences); $worksheet->write($row, $column_for{$errnum}, $occurences) while ($errnum, $occurences) = each %{$error_per_file{$filenam +e}}; ++$row; }
____________
Makeshifts last the longest.

In reply to Re: perl and excel by Aristotle
in thread perl and excel by Sara

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.