$first_data = "first.txt"; open(DAT,$first_data) || die("Could not open file!"); @seq1 = ; $second_file = "second.txt"; open (RF,$second_file) || die("Could not open file!"); @seq2 = ; my %hash = ( array1=>[@seq1], array2=>[@seq2] ); foreach my $value (%hash) { if($seq1 =~ $seq2){next;} else {print $value; exit;} }