in reply to Re^4: system command
in thread system command

Why you think so?

my $fileName = '/some/path/to/file.ext'; my $returnVal = `wc -l $fileName`;

Replies are listed 'Best First'.
Re^6: system command
by Fletch (Bishop) on Oct 31, 2007 at 13:36 UTC

    No, you've merely hidden the opening of the file down inside an external utility. The file is still being opened and completely read, you've just managed to introduce a layer of indirection and a fork/exec overhead.

    In order to count the number of lines in a file something is going to have to open the file and search through it for end-of-line markers. That is what he meant when said impossible.

    (Of course if you were dealing with a file that used fixed-length lines that still were newline terminated you could cheat and do it with stat and /, but for all normal intents and purposes "impossible" is still a reasonable pronouncement. :)