use strict; use warnings; use 5.010; open (my $LOGFILE, "<", "logfile.txt"); open (my $MATCHFILE, "<", "matches.txt"); chomp(my @keys = <$MATCHFILE>); close $MATCHFILE; #Initialize hash: my %target_matches; @target_matches{@keys} = (); #now the keys exist, and the values are undef my($num_records, $match_count) = (0, 0); while (<$LOGFILE>) { chomp; my @fields = split /,/; if (exists $target_matches{$fields[1]}) { $match_count++; } $num_records++; say "Total records: $num_records, matches: $match_count"; } close $LOGFILE;