Without studying your code (220 lines is a lot to ask of freebie help; 20 illustrating the same problem is much preferred), you might want to try profiling your code -- Dev::Deprof, Devel:NYTProf, etc. -- though your problem may be in the access time for data stored (somewhere... where?) with your "legacy...application." Also, you're running a lot of counters, each of which eats up cycles and could, as they and your export files get larger, slow your process.

And (afterthought!) if your data is in CSV files, why not inport the old data to a DB -- MySQL, SQLite, etc, and let the database engine do the counting and sorting? If necessary (and you may be able to export more-or-less direct to Excel files) the worst (IMO) that does is require you to reexport to CSV's and then export/store those as Excel files.

Hope this helps; I know it's not a careful review of your code nor an Rx for optomizing it, but as I said above, a post with 200+ lines of code (and no data) is a lot with which to burden the Monks. Please On asking for help & How do I post a question effectively?.


++$anecdote ne $data


In reply to Re: Optimization of script by ww
in thread Optimization of script by JulioRD

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.