> >And I'm thinking, perhaps I should get a unique list of all countries included >in this logfile and only then I can aggregate their Bytes by using regexp. > >Can you give me some hints on how I can accomplish this goal.. >
No regex is needed.You can use a hash to store the 'country' column and 'bytes' column then sort them for output. I wrote this test script and it works fine for me. use strict; my $ab = qq { 7491 | 210.23.185.123 | PH 202597706 7491 | 210.23.169.91 | PH 202594221 7303 | 201.252.130.245 | AR 201955854 9318 | 210.205.6.225 | KR 201892149 9930 | 210.19.229.57 | MY 201418551 9600 | 210.251.253.180 | JP 201362230 9929 | 210.82.176.84 | CN 201069109 7491 | 210.23.182.102 | PH 201006342 9600 | 210.251.253.180 | JP 201322301 4134 | 58.215.76.36 | CN 170125144 4844 | 210.23.5.177 | SG 170067928 }; my %re; for (split/\n/,$ab) { next unless $_; my ($country,$bytes) = (split)[4,5]; $re{$country}+=$bytes; } for (sort { $re{$b} <=> $re{$a} } keys %re) { print "$_: $re{$_}\n"; } __END__ Hope it helps. -- Books below translated by me to Chinese. Practical mod_perl: http://home.earthlink.net/~pangj/mod_perl/ Squid the Definitive Guide: http://home.earthlink.net/~pangj/squid/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>