in reply to cat vs. file handle speed?

Quick answer:
In an ideal world (and most cases), Perl will beat cat in a file read.
Caveat:
If you're running on Linux, this isn't the case, and cat is actually faster. See the enlightened node by tye on this subject here.
A minor work around (read ugly hack) to get Linux to work faster was to use a read statement, and break down the block into lines using a reader object. Seems to work for Linux, but will seriously slow down other OSes.
Malk

Replies are listed 'Best First'.
(tye)Re: cat vs. file handle speed?
by tye (Sage) on Mar 30, 2001 at 22:16 UTC

    Well, my analysis applies if cat uses "stdio.h" to read the file (which probably depends on the breed of cat that you have).

    But that doesn't matter in this case because even if cat is faster than Perl, Perl would still have to read the output from cat. So X+Y is always bigger than just Y (since a process can't consume negative resources), whether X<Y or Y<X.

            - tye (but my friends call me "Tye")