1 2 3 unwanted text 4 5 other stuff not numbers 6 7 8 #### while (<>) { chomp; next if /\D/; #will need more accurate regex depending on actual number format # process the lines that have only numbers }