in reply to Best way to read line x from a file
As others have said, this is wasteful because it reads the whole file while it should read only the first 9 lines.
If you want a solution that has no visible loop (or map etc), you could try using the module Tie::File. This module is in the standard Perl distrib. (Note that Tie::File numbers the lines with zero-offset.)
Otherwise, for me
seems the best solution but there might be a more elegant one.$l= <$F> for 1..9;
|
|---|