012345;23456;01005;11200;000111222;111222333
####
012345;23456;02006;22300;000001005;112004444
####
use strict;
use warnings;
( @ARGV == 2 and -f $ARGV[0] and -f $ARGV[1] )
or die "Usage: $0 input.table target.list\n";
my ( $infile, $targfile ) = @ARGV;
my $outfile = "OK.txt";
my $errfile = "ERROR.txt";
open( IN, $infile ) or die "$infile: $!";
open( OUT, $outfile ) or die "$outfile: $!";
open( ERR, $errfile ) or die "$errfile: $!";
open( TARG, $targfile ) or die "$targfile: $!";
my %target;
while () {
chomp; # target.list has lines like "01005;11400"
$target{$_} = undef;
}
close TARG;
while () {
my @fields = split /;/; # assuming no quoted ";" within fields
my $check = join ';', @fields[2,3]; # line-initial value is $fields[0]
# so 3rd and 4th are @fields[2,3]
if ( exists( $target{$check} )) {
print OUT;
} else {
print ERR;
}
}
close OUT;
close ERR;
####
my @targ_strings = ;
chomp @targ_strings;
my $targ_regex = join "|", @targs;
while () {
if ( /;(?:$targ_regex);/ ) {
print OUT;
} else {
print ERR;
}
}