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!

In reply to comparing columns using regular expression by rocky13

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.