in reply to Same code, same data, different execution times?

This would be the simpler, less memory-intensive way:
# Scan for source/dest pairs and count hits on each dest: $ipregex = qr/(?:\d{1,3}\.){3}\d{1,3}/; open(CAP, "$file"); while(<CAP>) { if ( /\s+($ipregex)\s+->($ipregex)\s+/ ) { $dest{$2}++; } } close CAP;
(I think your original post had a problem in the second part of your regex match. I took the easier way on that too.)

Replies are listed 'Best First'.
Re: Re: Same code, same data, different execution times?
by Anonymous Monk on Mar 21, 2003 at 18:00 UTC
    You need the "/o" option on the end of that regex or it is going to recompile it every time it is executed because of the variable inside of it.
      Ooops my bad. Missed you using the qr// construct. Apologies