Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Read Some lines in Tera byte file

by ikegami (Patriarch)
on Oct 13, 2010 at 06:36 UTC ( [id://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>; ... }

Replies are listed 'Best First'.
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?

      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.

      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?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (8)
As of 2024-04-19 11:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found