while (<$IN>) { chomp; next if /^#/; # discard line, it is a comment (starts with #) next if /^\s*$/; # discard line, contains only spaces next if length < $min_length; # line is too short next if /^REM/; # another form of comment next unless /^.{3}\d{4}/; # lines of interest have 4 digits from position 4 to 7 # now the real processing ... }