- 論壇徽章:
- 0
|
- #!/usr/bin/perl
- use warnings;
- use strict;
- use Data::Dumper;
- my @info;
- my %hash=();
- my $b;
- while (my $line = <DATA>) {
- @info = split /\s+/,$line;
- my($url,$byte) = ($info[6],$info[9]);
- $hash{$url} +=$byte;
- print "$url\t$hash{$url}\n";
- }
- __DATA__
- 192.168.0.151 - - [07/Nov/2012:19:47:34 +0800] "GET /php/js/messages.php?lang=en&db=&token=1b71fd2fb26e4cd28d35e229db661d0c HTTP/1.1" 200 16554
- 192.168.0.151 - - [07/Nov/2012:19:47:34 +0800] "GET /php/themes/pmahomme/img/logo_right.png HTTP/1.1" 200 4548
- 192.168.0.151 - - [07/Nov/2012:19:47:34 +0800] "GET /php/themes/pmahomme/img/input_bg.gif HTTP/1.1" 200 170
- 192.168.0.151 - - [07/Nov/2012:19:47:34 +0800] "GET /php/themes/dot.gif HTTP/1.1" 200 43
- 192.168.0.151 - - [07/Nov/2012:19:47:34 +0800] "GET /php/themes/pmahomme/img/sprites.png HTTP/1.1" 200 38291
- 192.168.0.151 - - [07/Nov/2012:19:47:34 +0800] "GET /php/themes/pmahomme/img/s_error.png HTTP/1.1" 200 664
- 192.168.0.151 - - [07/Nov/2012:19:47:34 +0800] "GET /php/themes/pmahomme/img/s_error.png HTTP/1.1" 200 629
復(fù)制代碼 這個(gè)是重復(fù)的 /php/themes/pmahomme/img/s_error.png 所以想相加后邊 664和629 。我這樣寫的結(jié)果不對(duì),請(qǐng)大家棒棒忙。。
應(yīng)該是用hash但是一直不知道怎么使用 |
|