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):if ( @ips = $line =~ /[\d.]{7,15}/g ) { $client_ip{$ips[0]}{$iteration}++; . . . }
Or, of course combine them: if ( $line =~ /^\s*($iprx):\d+\s*->\s*($iprx):\d+\s*->\s*($iprx)/ ) {$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/ ) { . . . }
In reply to Re: Regex redux
by petral
in thread Matching an IP address
by ibanix
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |