read last line without reading previous lines, how? 
Author Message
 read last line without reading previous lines, how?


Quote:
> I wonder how to reading the last line of a text file, without going
> through the previous lines.

This FAQ entry has some info about that. Hope this helps!

    http://www.*-*-*.com/
          How_do_I_change_one_line_in_a_fi.html

--
Tom Phoenix           http://www.*-*-*.com/ ~rootbeer/

Randal Schwartz Case:   http://www.*-*-*.com/



Sun, 02 Jan 2000 03:00:00 GMT  
 read last line without reading previous lines, how?

Hi,

I wonder how to reading the last line of a text file, without going through
the previous lines.  Thanks.



Sun, 02 Jan 2000 03:00:00 GMT  
 read last line without reading previous lines, how?

|> Hi,
|>
|> I wonder how to reading the last line of a text file, without going through
|> the previous lines.  Thanks.

Look up the man pages for 'seek', there is a mode to seek to the end of a file.
--
Helmut Jarausch
Lehrstuhl f. Numerische Mathematik
Institute of Technology, RWTH Aachen
D 52056 Aachen, Germany



Tue, 04 Jan 2000 03:00:00 GMT  
 read last line without reading previous lines, how?

Try ...



--
                           Jeff Wilson
                           London - UK




Quote:
Wang) writes:

: |> Hi,
: |>
: |> I wonder how to reading the last line of a text file, without
going through
: |> the previous lines.  Thanks.
:
: Look up the man pages for 'seek', there is a mode to seek to the end
of a file.
: --
: Helmut Jarausch
: Lehrstuhl f. Numerische Mathematik
: Institute of Technology, RWTH Aachen
: D 52056 Aachen, Germany
:


Sun, 09 Jan 2000 03:00:00 GMT  
 read last line without reading previous lines, how?


Quote:
> Subject: Re: read last line without reading previous lines, how?

> Try ...

> open(TXT,"<textfile");



That doesn't read the last line without reading previous lines. You should

should be referenced as $fred[-1] . Thanks for trying!

--
Tom Phoenix           http://www.teleport.com/~rootbeer/

Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



Sun, 09 Jan 2000 03:00:00 GMT  
 read last line without reading previous lines, how?

Quote:

> Try ...

> open(TXT,"<textfile");

Don't forget to check the return value of open...

But this reads *all* the lines in textfile...

Quote:

> : |> I wonder how to reading the last line of a text file, without
> going through
> : |> the previous lines.  Thanks.

Scott

--
Scott I. Blanks{*filter*}
sib (at) worldnet (dot) att (dot) net



Sun, 09 Jan 2000 03:00:00 GMT  
 read last line without reading previous lines, how?


Quote:


Wang) writes:
> |> Hi,
> |>
> |> I wonder how to reading the last line of a text file, without going through
> |> the previous lines.  Thanks.

> Look up the man pages for 'seek', there is a mode to seek to the end of
a file.
> --
> Helmut Jarausch
> Lehrstuhl f. Numerische Mathematik
> Institute of Technology, RWTH Aachen
> D 52056 Aachen, Germany

or use

system "tail","-1",$file; #?or some such variant

Bob

--
.sig file on holiday



Sun, 09 Jan 2000 03:00:00 GMT  
 read last line without reading previous lines, how?



Quote:

>> open(TXT,"<textfile");
>Don't forget to check the return value of open...

>But this reads *all* the lines in textfile...

>> : |> I wonder how to reading the last line of a text file, without
>> going through
>> : |> the previous lines.  Thanks.

The only method which is system independant would be to fseek() to the end
of the file, and then iterate back one byte at a time until you hit a newline-
you could even build the line as you go (backwards, of course).


Mon, 10 Jan 2000 03:00:00 GMT  
 read last line without reading previous lines, how?

a similar question is:  "how can i read a file from last line to
first?"  i'm probably looking for a pre-written function that doesn't
store the entire file in an array, and it doesn't step through the
entire file for each line.

thanks.

Quote:

> Try ...

> open(TXT,"<textfile");


> --
>                            Jeff Wilson
>                            London - UK




> (Chuan
> Wang) writes:
> : |> Hi,
> : |>
> : |> I wonder how to reading the last line of a text file, without
> going through
> : |> the previous lines.  Thanks.
> :
> : Look up the man pages for 'seek', there is a mode to seek to the end

> of a file.
> : --
> : Helmut Jarausch
> : Lehrstuhl f. Numerische Mathematik
> : Institute of Technology, RWTH Aachen
> : D 52056 Aachen, Germany
> :



Tue, 11 Jan 2000 03:00:00 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. how to read a huge file line by line without loading it into memory

2. Reading Last X Lines of File?

3. Quickly read the last 10 lines of a very large logfile

4. Reading last 3 lines from the file

5. read last line only...

6. Reading the last line of a file

7. best way to read last line?

8. how to read in line by line?

9. read line by line

10. Limiting maximum line length during line based read

11. read line by line in perl

12. how to read in line by line?

 

 
Powered by phpBB® Forum Software