There is a lot of files that's going to be opened a lot of times, so I just want to be sure that this link in the chain is optimal
So, you want to make sure the most optimal way of closing your car door, because you are going to make a lot of road trips? Even if it's just trips to the shop, it's not significant.
The thing I'm most concerned with is the best way to put the file in the variable.
Ah, but where's the printing aspect?

Anyway, it's faster to read it in one go instead of first putting it in an array, then joining them one line at the time:

my $text = do {local $/; <FILE>};
Or you can use sysread, but you'll have to benchmark if that's faster.

You also may be able to tweak your filesystem/volumemanager/storagemanager to get a better performance. After all, your road trip gets shorter if you make use of tarmac roads instead of dirt roads. Regardless of the car you use, or your driving skills.


In reply to Re^5: Most efficient way to print a file? by JavaFan
in thread Most efficient way to print a file? by Anonymous Monk

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.