... I'm ... concerned about why these regexs are so expensive.
... 98% of run time is tied to these regexs.

We see data being read and munged in the code shown in the OP. The inference I draw from the OP is that the only code not shown is to open the file, write the munged data and close the file. As such, there's almost nothing happening other than data munging done by regexes and, as jwkrahn points out, a possibly expensive string prepend. I don't understand why one would expect the great majority of time to be spent other than in regex execution given the length of the strings involved.

... my substitutions ... are slow.

But what does 'slow' mean? A day? An hour? A minute? My guess is that the regexes shown in the OP would take on the order of a minute or so per file. Is this MajingaZ's experience? How fast do they need to be?


In reply to Re: Making CSV Files from Tab Delimited Files by AnomalousMonk
in thread Making CSV Files from Tab Delimited Files by MajingaZ

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.