CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
starting at the end of file

 



andrew_b
stranger

Jun 14, 2005, 9:16 AM

Post #1 of 3 (702 views)
starting at the end of file Can't Post

I would like to read/process a file line by line starting with the last line and work toward the first... without reading the whole file in first. Any way to do this?

Many thanks.


KevinR
Veteran


Jun 14, 2005, 10:29 AM

Post #2 of 3 (698 views)
Re: [andrew_b] starting at the end of file [In reply to] Can't Post

should be able to do that with Tie::File

read the Tie::File documentation and it will explain, it's a pretty easy module to understand and use since you basically treat the file like any other perl array, even though it's not read into memory.

There are probably other ways too.
-------------------------------------------------


davorg
Thaumaturge / Moderator

Jun 15, 2005, 5:07 AM

Post #3 of 3 (689 views)
Re: [andrew_b] starting at the end of file [In reply to] Can't Post

As KevinR says, Tie::File can do this and is a standard part of any recent (5.8.x) version of Perl.

Another option might be File::ReadBackwards.

--
Dave Cross, Perl Hacker, Trainer and Writer
http://www.dave.org.uk/
Get more help at Perl Monks

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives