Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: Read Some lines in Tera byte file

by Anonymous Monk
on Oct 13, 2010 at 06:50 UTC ( #865021=note: print w/ replies, xml ) Need Help??


in reply to Re: Read Some lines in Tera byte file
in thread Read Some lines in Tera byte file

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?


Comment on Re^2: Read Some lines in Tera byte file
Select or Download Code
Re^3: Read Some lines in Tera byte file
by Corion (Pope) on Oct 13, 2010 at 06:53 UTC

    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?

        Yes. See perlfunc. Also, Google is helpful. If the file is on a remote server, then seek will only work if you can mount the remote filesystem locally.

      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?

        Perl has seek as a builtin. It's not gonna help solve the question you asked us, though.
Re^3: Read Some lines in Tera byte file
by ikegami (Pope) on Oct 13, 2010 at 07:53 UTC
    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://865021]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2014-07-31 01:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (244 votes), past polls