in reply to Matching an IP address

Is there a better way I can do the (\d+\.\d+\.\d+\.\d+)? As you can tell, I'm just trying to match for a numeric IP address.

Take a look at Regexp::Common::net. Your code could be written as something like (untested code):

use Regexp::Common qw /net/; # match dotted decimal IP address # $1 = whole match, $2-5 = bytes my $IP = $RE{net}{IPv4}{-keep}; foreach my $line (@connections) { if ($line =~ /^\s*$IP:\d+\s*->\s*$IP:\d+\s*->\s*$IP/x) { $client_ip{$1}{$iteration}++; $vips{$6}{$iteration}++; $frontend{$11}{$iteration}++; } }

Note that $IP will only match on legal decimal IP addresses (so 666.666.666.666 won't match). This may, or may not, be what you want ;-)