in reply to Re: Re: *Fastest* way to print a hash sorted by value
in thread *Fastest* way to print a hash sorted by value

I know this is a Perl forum, but sometimes Perl by itself is not the best tool for the job. You might consider testing the speed of using another program like sort(1) on the file before processing it with Perl (or just run sort from your Perl program).

Check out the helpful advice in this thread: Fast/Efficient Sort for Large Files

Then, you can read in the lines until you have the top N values and you're done.

If your log files are not easily sortable using sort(1) because of strange formatting and delimiters (like web server access logs), you may pre-process them (with Perl, of course) so that they have nice column separators for sort to recognize.

  • Comment on Re: Re: Re: *Fastest* way to print a hash sorted by value