Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Read Some lines in Tera byte file

by ikegami (Pope)
on Oct 13, 2010 at 06:36 UTC ( #865019=note: print w/ replies, xml ) Need Help??


in reply to Read Some lines in Tera byte file

Unless you happen to know the position at which the 100th line starts, you'll have to read from the start of the file. You can stop reading any time, though.

for (1..100) { <$fh>; } for (1..100) { my $line = <$fh>; ... }


Comment on Re: Read Some lines in Tera byte file
Download Code
Re^2: Read Some lines in Tera byte file
by Anonymous Monk on Oct 13, 2010 at 06:50 UTC

    Thanks for reply

    Here ..

    for (1..100) { <$fh>; }

    we are reading from 1st line to 100th lines, then

    for (1..100) { my $line = <$fh>; ... }

    we are saving required to a variable i.e from position 100th line 200th line

    So unnecessary reading first 100 lines in the first code, is it possible directly read from 100th line?

      No.

        because i said file is in tera bytes, so if my file reading position is nth (ex : 99999999) then it will be difficult to parse all lines and consuming time also.

        do we have function in perl like seek?

        because i said file is in tera bytes, so if my file reading position is nth (ex : 99999999) then it will be difficult to parse all lines and consuming time also.

        do we have function in perl like seek?

      Already answered. Unless you happen to know the position at which the 100th line starts, you'll have to read from the start of the file. If you do, you can jump straight to that position using seek.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://865019]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2014-08-20 23:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (125 votes), past polls