seek LOGFILE, 0, 0; while () { if (/rev_(\d+)/) { print if $1 == $max_id } }