in reply to The need for speed

Just looking at your sub process _it

I believe that the sub could be reduced to somthing like the following at least. This is completely untested, and changed by (quick) inspection only , but I think it should be close and run quite a bit quicker. As it is called many times at the heart of your application, it might make a substantial difference to your run times. I'd like to here the results.

I think you could also consolidate at least 1 if not both of the temporary count vars $tmp_c & $total_c, but I couldn't wrap my head around the logic.

sub process_it { my ($rec_line) = grep(/received from internet:/, @_); my ($from, $tmp) = ( split(/:/, $rec_line) )[3, -1]; $from =~ s/(fromhost=|$CHARS)//g; my $count = $tmp =~ s/@/@/g; my @data = grep(!/received from internet:/ and !/Error-Handler/, @ +_); my $total_c; foreach my $line (@data) { my @line = split(/:/, $line); my ($tmp_c, $type); if ($line[0] =~ /( |-)([a-zA-Z]+)$/) { $type = $states{$2}; warn "NO type: $line[0]\n" if ($type =~ /^(\s+|)$/); $tmp_c += ($type =~ /del_rem/) ? $line[$#line] =~ tr/@/@/ +: 1; } $by_type{$from}{$type} += $tmp_c; $total_c += $tmp_c; } $by_ips{$from}+= $total_c; }

A quick scan of the rest of the code suggests that some of these changes could be beneficial there too, but that's left as AEFTP.

Hope it helps some.


Examine what is said, not who speaks.

The 7th Rule of perl club is -- pearl clubs are easily damaged. Use a diamond club instead.