Hi,
I am working on a script that will allow me to read from two files, compare the entries and output invalid entries.
TFILE contains entries such as:
11111_
11112_
11113_
11234_
12342_
FILE1 contains entries such as:
11111_A
11112_A
11113_A
11234_A
12342_A
11111_B
11112_B
11113_B
11234_B
12342_B
Now for every entry in TFILE there should be an entry beginning with the same number but ending in B in FILE1. If there is not such an entry in FILE1 then this be considered as an invalid entry and will be output to the screen stating that it is missing.
So far I have the following, but it is not working:
#!/usr/bin/perl -w
use strict;
my $trecord;
open(TFILE, "<tfile.txt") || die "Cannot open: $!";
open (FILE1, "<aaa.txt");
while ($trecord = <TFILE>) {
while (<FILE1>){
if (( $trecord =~ m/($trecord)/) && ( $trecord !~ m/(_B)/)){
print $trecord;
print "\n";
}
}
}
close(FILE1);
close (TFILE);
Currently when I run this program I get a long list of the first entry from TFILE.
Any assistance would be appreciated. Thank you.
I am working on a script that will allow me to read from two files, compare the entries and output invalid entries.
TFILE contains entries such as:
11111_
11112_
11113_
11234_
12342_
FILE1 contains entries such as:
11111_A
11112_A
11113_A
11234_A
12342_A
11111_B
11112_B
11113_B
11234_B
12342_B
Now for every entry in TFILE there should be an entry beginning with the same number but ending in B in FILE1. If there is not such an entry in FILE1 then this be considered as an invalid entry and will be output to the screen stating that it is missing.
So far I have the following, but it is not working:
#!/usr/bin/perl -w
use strict;
my $trecord;
open(TFILE, "<tfile.txt") || die "Cannot open: $!";
open (FILE1, "<aaa.txt");
while ($trecord = <TFILE>) {
while (<FILE1>){
if (( $trecord =~ m/($trecord)/) && ( $trecord !~ m/(_B)/)){
print $trecord;
print "\n";
}
}
}
close(FILE1);
close (TFILE);
Currently when I run this program I get a long list of the first entry from TFILE.
Any assistance would be appreciated. Thank you.