G'day davidinottawa,

I'd approach this in a number of different ways to what you've posted:

Putting all that together (pm_1153098_match_csv_lines.pl):

#!/usr/bin/env perl -l use strict; use warnings; use autodie; use Text::CSV; my $input_file = 'pm_1153098_match_csv_lines_input.csv'; my $pattern_file = 'pm_1153098_match_csv_lines_pattern.txt'; my %match_pattern; open my $pat_fh, '<', $pattern_file; while (<$pat_fh>) { chomp; ++$match_pattern{$_}; } close $pat_fh; my $csv = Text::CSV::->new({sep_char => '|'}); open my $in_fh, '<', $input_file; while (my $row = $csv->getline($in_fh)) { print $row->[1] if $match_pattern{$row->[1]}; } close $in_fh;

With these files:

$ cat pm_1153098_match_csv_lines_input.csv David@domain.com|David@domain.com|J|ABBASS, DAVID JOHN| Cory@domain.com|Cory@domain.com|E|ABBOTT, CORY J| Tania@domain.com|Tania@domain.com|F|ABBOTT, TANIA LEE| Geoffrey@domain.com|Geoffrey@domain.com|N|ABBOTT, GEOFFREY BRYAN|
$ cat pm_1153098_match_csv_lines_pattern.txt Randall@domain.com David@domain.com Rob@domain.com Tania@domain.com

I get this output:

$ pm_1153098_match_csv_lines.pl David@domain.com Tania@domain.com

— Ken


In reply to Re: Look for pattern in file. ???? by kcott
in thread Look for pattern in file. ???? by davidinottawa

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.