%hash = {'match1'=> 1; 'match2' => 1; } foreach $row (@file) { if (exists hash{$$row[0]}) { ## do something } } #### open (FILE, "<$file") or die $!; @file = ; foreach $row (@file) { ## do something with $row }