open AD, "file1.txt"; @arr=; foreach $line(@arr) { $name{substr($line,0,4)}++; } close AD; #hash out of the contents of the first file=MADE #----------- open FH, "file2.txt"; @arr2=; foreach $a(@arr2) { @val=split(' ',$a); foreach $v($#val) if (...what do i do here???..) {print..... } }