in reply to Perl Optimization

Using a single precompiled regex may help:

my $matchStr = join '|', map {$hash{$_}[0]} keys %hash; my $match = qr/($matchStr)/i; while (my $cur_line = <fh_log>) { #If this query contains reference to this table next if $cur_line !~ $match; #count up how many times this table is referenced. $table_stats{$1}++; $table_refs++; #total table references (for % calc) }

Perl reduces RSI - it saves typing

Replies are listed 'Best First'.
Re^2: Perl Optimization
by ikegami (Patriarch) on Aug 09, 2008 at 00:29 UTC

    Oops, I took (way) too long to write my post. But there are a couple of bugs in yours.

    1. $table_stats{$1}++; should be $table_stats{lc($1)}++;

    2. You only count one table per line, whereas the OP counts every table per line.

    Also, I used Regexp::List to improve performance when there are similar table names (fairly likely). That feature is already built into Perl 5.10, though.