#!/usr/bin/perl use strict; use warnings; my $bytes; open(FILE, "squid.log") or die $!; while() { next unless m/\d+\s\d+\s\d+.\d+.\d+.\d+\s\w+\/\d+\s(\d+)\s\w+\s(.*?)\s(?!-)\w+\s\w+\/(?!172.\d+.\d+.\d+)/; #1257981327.964 212098 172.16.32.142 TCP_MISS/200 3037 CONNECT mail.google.com:443 rgabriel DIRECT/172.16.32.14 - $bytes += $1; } close(FILE); print "$bytes\n";