Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Re: Best way to read line x from a fileby ambrus (Abbot) |
on Mar 29, 2004 at 18:32 UTC ( [id://340700]=note: print w/replies, xml ) | Need Help?? |
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.
In Section
Seekers of Perl Wisdom
|
|