From: Holden Glova Date: 2001-03-25T16:50:17+09:00 Subject: [ruby-talk:13192] Re: Reading a file backwards -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Sun, 25 Mar 2001 14:10, I think Daniel Berger wrote: > Hi all, > > Old Perl programmer, new to Ruby. Is there a method/module out there for > reading a file backwards? This would be useful for logfiles, for example. > > Thanks in advance. > > Dan Hi Dan, perhaps something like this is what you want? synack@eugene:~/tmp/fox-0.99.166/textedit$ cat > testFile line 1 line 2 line 3 synack@eugene:~/tmp/fox-0.99.166/textedit$ irb irb(main):001:0> f = File.new("testFile") # irb(main):002:0> f.readlines.reverse.each { |line| p line } "line 3\n" "line 2\n" "line 1\n" ["line 3\n", "line 2\n", "line 1\n"] Hope this helps you some. - -- Signed, Holden Glova -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.4 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE6vZ4czrxa+Gy/b/4RAuzxAJ9FDBHhSliQ53y4ucDcnUrvd8655wCgmp1j TM8/q0Njq/WKOrBh1piFN78= =mY0s -----END PGP SIGNATURE-----