while (<$fh>) { next if /23456/; # further processing of lines not containing 23456 }