in reply to Fastest way to get input from a filehandle

I would expect the fourth one is the slowest, since you're going out of your way to get a line. The first three are, I believe, identical.

But this is not where you should be looking for speed increases in your code. This is such a minor issue. You're over-optimizing.


Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart
  • Comment on Re: Fastest way to get input from a filehandle

Replies are listed 'Best First'.
Re^2: Fastest way to get input from a filehandle
by sauoq (Abbot) on Oct 29, 2005 at 16:34 UTC

    I would think the 2nd would be slowest since there is an extra step of getting the right filehandle from the string...

    $ perl -MO=Deparse -e 'readline(STDIN)' readline 'STDIN'; -e syntax OK
    Not sure when that happens though. (One time penalty?)

    I would expect the fourth to be about as quick as the others (after the open) as it's just dup'ing STDIN. Is it slower to store a filehandle in a lexical? (I wouldn't think so but have no real clue.)

    shrug

    Not that any of this changes the fact that it shouldn't matter to the OP. :-)

    -sauoq
    "My two cents aren't worth a dime.";