http://www.perlmonks.org?node_id=883048

rocky13 has asked for the wisdom of the Perl Monks concerning the following question:

I have two files. File1 has three columns and file2 has one column. File2 is a subset(w/ some repetitions) of the second column from file1. Here is a subset of the data for each file:

file1: Box of Joe CA12DE 12345 Big Box BA23DF 0123X Small FFFFF3 111XX Big and Small 4F4FGG XCA12 None XXXXXX 00000 file2: BA23DF BA23DF 4F4FGG

I need to print the entire line from file1 that does NOT contain the rows in file2. The output should look like this:

Name Number Count Box of Joe CA12DE 12345 Small FFFFF3 0123X None XXXXXX 00000
#!/usr/bin/perl open(F1 "<file1.txt") or die "Can't open\n"; open(F2 "<file2.txt") or die "can't open\n"; my @field = (); foreach (my $line = <F2>) { push (@field, $line); } my $string = join(",",@field); my @f = split(/,/, $string); my @unique_f = split(/,/, unique(@f)); while ($m_line = <F1>) { if !($m_line =~ m/????????/i) sub unique { my %seen = (); my @r = (); foreach my $a (@_) { unless ($seen{$a}) { push @r, $a; $seen{$a} = 1; } } return @r; } #I have gotten this far but now I want to use regular expression that +matches each entry of the second column of file1 to the entire @uniqu +e_f. Thus, if the match is NOT DEFINED, then it should print the who +le line. Thanks!