#!/usr/bin/perl -w use strict; use Benchmark; my $now = 8; # we'll pretend it's between 8 and 9 PM my %url = ( monday => { @{[map(($_,1), (1..1000))]} } ); timethese(100000, { a => q{ $now = (sort grep {$_ <= $now} keys %{$url{'monday'}})[-1]; }, b => q{ $now = ($now < $_ && $_ < 8 ? $_ : $now) for keys %{$url{'monday'}}; } });