Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
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>; ... }

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
Node Status?
node history
Node Type: note [id://865019]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2017-06-26 03:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (572 votes). Check out past polls.