http://qs321.pair.com?node_id=214333


in reply to Matching an IP address

if ( @ips = $line =~ /[\d.]{7,15}/g ) { $client_ip{$ips[0]}{$iteration}++; . . . }
If you need to check the validity of the line, you can wrap that in something like (using the regex from Mastering Reg Exps as cited here):
$numrx = qr/[01]?\d\d?|2[0-4]\d|25[0-5]/; $iprx = qr/($numrx\.){3}$numrx/; if ( $line =~ /^(\s*($iprx):\d+\s*->){2}\s*$iprx/ ) { . . . }
Or, of course combine them: if ( $line =~ /^\s*($iprx):\d+\s*->\s*($iprx):\d+\s*->\s*($iprx)/ ) {
  p