in reply to Matching an IP address

Well, assuming you want to stick with this regex for ip's (which allows things like 999.012.4231.31245 - see Matching an IP address), you could just define it beforehand:
my $ip = qr/\d+\.\d+\.\d+\.\d+/; foreach $line (@connections) { if ($line =~ /^\s*($ip):\d+ \s*->\s*($ip):\d+ \s*->\s*($ip)/x) { $client_ip{$1}{$iteration}++; $vips{$2}{$iteration}++; $frontend{$3}{$iteration}++; } }

-- Dan