#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11126426 use warnings; use Search::Dict; use Date::Parse qw( str2time ); use Time::HiRes qw( time ); my $day = 60 * 60 * 24; # commented code used to create 209M file; #my $str = join '', map { localtime( time + $_ * $day) . # " kernel: log entry\n" } -5e6 .. 5; #print $str; #use Path::Tiny; path('d.searchdict')->spew($str); #print "string length = @{[length $str]}\n"; my $want = time - 1.1 * $day; my $start = time; open my $fh, '<', 'd.searchdict' or die; look $fh, $want, { comp => sub { $_[0] <=> $_[1] }, xfrm => sub { str2time substr shift, 0, 24 }, }; printf "look took %.3f seconds\n", time - $start; while( <$fh> ) # now read to end of file { print; }