Well, unless getc() works differently on non-unix systems (and it wouldn't surprise me), it's documented to read until EOF, so the while(not(eof(X))) doesn't seem necessary. getc() doesn't care about newlines.
Even given the possible less-than-best read performance of getc() relative to <FILE>, I'd still expect the getc loop to be faster, since even though regexps are fast, not having to use them at all is faster still. Doing a split or a s/// on each line of input is likely to kill your speed gain.
Of course, there are trade offs... if all your files are small, you probably don't care if you have the fastest three lines. For anything other than looking at each character in the file, using getc() probably will suck. But if it's applicable, benchmark whatever alternatives you're looking at... On my box, a getc() loop was significanly faster than <FILE>...

In reply to RE: RE: Re: How To Do This Better? by NoTwoGroo
in thread How To Do This Better? by buzzcutbuddha

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.