#!/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;