my %htable_re; #reading in small file while($cur_line=) { my @command=split(/;;;+/,$cur_line); $htable_re{$command[0]}=qr/\b($command[0])\b/i #parse remainder of line... } #pattern match against big file while() { foreach $key (keys %htable_re) { if(/$htable_re{$key}/ ) #If this query contains reference to this table { $table_stats{$key}++; #count up how many times this table is referenced. $table_refs++; } } }