#!/usr/bin/perl -w
use strict;
open my $config, "config.cfg" or die "config.cfg: $!\n";
# Assuming the config file structure is one error per line
my %errlist = map { chomp; $_ => 1 } <$config>;
close $config;
open my $log, "logfile.txt" or die "logfile.txt: $!\n";
while (<$log>){
chomp;
/:([^:]+)$/;
print "Error '$1' found on line $.\n" if exists $errlist{$1};
}
In other words, you use the hash to store all your "valid errors", then check the actual errors against that hash. Fairly common algorithm, certainly in Perl.
--
"Language shapes the way we think, and determines what we can think about."
-- B. L. Whorf
|