It processes a 50,000 line file in about 70 milliseconds. ... I've heard Perl is a performant scripting language.

With those kinds of execution times, personally I wouldn't even worry about it to begin with. But just to demonstrate that Perl isn't going to be a lot slower, here's an example benchmark from my system (somewhat simple, just average execution time over a couple of runs). The first row is your code (unchanged), and the following three rows are the three pieces of code I posted:

Input file size
Solution 12 lines 120_000 lines 1_200_000 lines
awk 26ms 66ms 417ms
awk to Perl 26ms 105ms 782ms
First example 27ms 75ms 520ms
Second example 27ms 72ms 450ms

This is Perl 5.24.1 on Linux. As you can see, although awk might have a minor advantage, I don't think you have anything to worry about in terms of speed when it comes to your use case. If it ever came to be an issue, there are lots of ways to optimize code in Perl (e.g. Benchmark and profilers like Devel::NYTProf).


In reply to Re: Filtering certain multi-line patterns from a file by haukex
in thread Filtering certain multi-line patterns from a file by ivanbrennan

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.