while (<>) { chomp; next if /\D/; #will need more accurate regex depending on actual number format # process the lines that have only numbers }