#!/usr/bin/perl -w use strict; my @all = ("7723","7725","9908","7765","7874"); while () { # ... your code to check the current line }: __DATA__ 77876 8543 CA84985 54E 77873 8003 CA84985 54E 77875 7725 CA84985 54E ...