use strict; use warnings; #this script is to match the two files and print the matched content i+n the two files open (FILE1,"; my @array=split(' ',$var); open (FILE2,") { chomp; push(@new, $_); } my $i; my $line; open(OUT,">nrset.txt"); foreach $line (@array) { chomp $line; for($i=0;$i<$#new;$i++) { chomp $new[$i]; if ($new[$i]=~/$line/i) { print OUT "$new[$i]\n$new[$i+1]\n"; } } }