#!/usr/bin/perl open(FILE2, "; %hash2 = @hash{@lines2}; open(FILE1, "; foreach (@lines1) if ($_ == %hash2); %hash2 +=1