my $last_time = time; sort { if (time - $last_time > 1) { $mw->update(); }; $a <=> $b } @list;