in reply to efficient way to read a file in reverse

> I also have to use what is installed on these machines (of which there are thousands of them I need to run it on), so that rules out using File::ReadBackwards

It's pure Perl, you could even copy the rather short code into a module of yours.

If you wanna implement it yourself I'd try reading sliding windows˛ of 4^n kb chunks from the end with seek

I'd put all the logic into a sub which returns those lines or maybe I'd try to create a new IO class.

I remember a similar question not too long ago, you should try super search °

update

°) like Reading the contents of a file from the bottom up

˛) sliding windows explained

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

  • Comment on Re: efficient way to read a file in reverse

Replies are listed 'Best First'.
Re^2: efficient way to read a file in reverse
by hippo (Archbishop) on Jan 06, 2021 at 14:06 UTC
    you could even copy the rather short code into a module of yours.

    Or better still, use App::FatPacker to create your stand-alone, distributable script. It will do all the hard/dull work so you don't have to.


    🦛

Re^2: efficient way to read a file in reverse
by cmcl (Novice) on Jan 06, 2021 at 17:16 UTC

    Thanks for the suggestions Rolf. I think adapting the code from the module sounds like the best bet, though taking a look at the module, I will need to do my homework on what a lot of it means (I only dabble with scripting really), so a good learning exercise!

    Cheers,
    Cam
      Hmm it's offering a "tie filehandle" interface, that's not common and rather deep for a beginner (though a good idea)

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery