Beefy Boxes and Bandwidth Generously Provided by pair Networks httptech
"be consistent"
 
PerlMonks  

Re: Best way to read line x from a file

by ambrus (Abbot)
on Mar 29, 2004 at 13:32 UTC ( [id://340700]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


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

$l= <$F> for 1..9;
seems the best solution but there might be a more elegant one.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://340700]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.