my $log_pattern = qr{ ^ ([\s.]+) \s # match the IP address - \s - \s # ignore these fields \[([^]]+)\] # here's probably where your problem was ... }x;