my %tables = map { lc($hash{$_}[0]) => 1 } keys %hash; while (my $cur_line = <$fh_log>) { while ($cur_line =~ /(\w+)/g) { my $table = lc($1); if ($tables{$table}) { # Count up how many times this table is referenced. $table_stats{$table}++; $table_refs++; } } }