- 论坛徽章:
- 7
|
kankan:- #!/usr/bin/perl
- my $log = '/tmp/dl/mytestlog';
- open my $f, $log or die "$log: $!";
- my ( %ip, %id );
- while (<$f>) {
- my ($ip) = /^(\S+)/;
- my %a = /(areaid|type|appid)=(\w*)[%&]/g;
- $ip{$ip}++;
- next if !$a{appid};
- $id{ $a{appid} }{c}++;
- $id{ $a{appid} }{type}{ $a{type} }++ if $a{type};
- $id{ $a{appid} }{areaid}{ $a{areaid} }++ if $a{areaid};
- }
- while ( my ( $k, $v ) = each %id ) {
- print "id:\t", $k, $/;
- print "times:\t", $v->{c}, $/;
- print "type:\t", join( ', ', keys %{ $v->{type} } ), $/;
- print "areaid:\t", join( ', ', keys %{ $v->{areaid} } ), $/, $/;
- }
- print $/;
- while ( my ( $k, $v ) = each %ip ) {
- print "$k\t$v$/";
- }
复制代码 |
|