in reply to Efficient Way to Parse a Large Log File with a Large Regex
use strict; my @ips = ( "192.1.20.1", "192.1.20.2", ); my %ips = map { $_=>1 } @ips; open LOG, "<", "logfile" or die $!; while ( <LOG> ) { #match ip-address if ( /(([0-9]+\.)+[0-9]+)/ ) { if ( $ips{$1} ) { # do found ip stuff here } else { #do other stuff here } } } close LOG;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Efficient Way to Parse a Large Log File with a Large Regex
by Grygonos (Chaplain) on Apr 12, 2005 at 20:38 UTC |