in reply to Re: Perl Optimization
in thread Perl Optimization

Thats a great idea which had not occured to me. I was not in fact using precompiled regexps, but when I switched to them it seemed to slow down my code (from 25-30 secs on my test data set to 3+ minutes). I'll give the search reversal a try and let you know how it turns out. Updated code using precompiled regex:
my %htable_re; #reading in small file while($cur_line=<size_log>) { 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(<fh_log>) { foreach $key (keys %htable_re) { if(/$htable_re{$key}/ ) #If this query contains reference to t +his table { $table_stats{$key}++; #count up how many times this table +is referenced. $table_refs++; } } }