I have two files:
File1:
M1U152S44906X14127_xu
M1U7S112336U117688_xu
File2 (tab delimited):
T1X19S17508N179711_xu AAU_779
M1U152S44906X14127_xu xcup
M1U7S112336U117688_xu mmna
I want to search the content of File 2 using the content of File 1 and then display the output as follows:
Date of search:
The following matches were found in File 1:
T1X19S17508N179711_xu Nothing found
M1U152S44906X14127_xu xcup
M1U7S112336U117688_xu mmna
my code:
#!C:\bin\perl.exe
use warnings;
use strict;
my $REPORT_FILE = 'outFile.txt';
my $F1 = 'File1.txt';
open(RF,"<$F1") || die "can't open $F1 $!";
my $F2 = 'File2.txt';
open(RXNs,"<$F2") || die "can't open $F2 $!";
my %line;
my %var1;
my %var2;
while (my $line = <RF>){
$line = split('\t');
$var1{$1} = {2};
}
close(RF);
while (my $line = <RXNs>){
$line = split('\n');
$var1{$2}={1};
}
close(RXNs);
open(DATA,"+>OutFile.txt") or die "Can't open data";
if (exists $var1{$var2}){
print DATA $var1{1}."\t".$var2{2}."\n" ;
}
else {
print "$var2 not found in the file\n"; #Here I want the program to output - Nothing found
}
close DATA;
This code returned errors that I have not been able to solve.
Please help!!!
Thanks