Chinaunix首页 | 论坛 | 博客
  • 博客访问: 835499
  • 博文数量: 253
  • 博客积分: 6891
  • 博客等级: 准将
  • 技术积分: 2502
  • 用 户 组: 普通用户
  • 注册时间: 2010-11-03 11:01
文章分类

全部博文(253)

文章存档

2016年(4)

2013年(3)

2012年(32)

2011年(184)

2010年(30)

分类: Python/Ruby

2011-10-21 22:47:30

  1. #!/usr/bin/perl -w

  2. use strict;

  3. my %hash;
  4. my $all = "all bytes";

  5. while(<>){
  6.     chomp $_;
  7.     next if(/^#|^$/);
  8.     my ($src, $dst, $bytes) = split;
  9.     $hash{$src}{$dst} = $bytes;
  10.     $hash{$src}{$all} += $bytes;
  11. }
  12. for my $source (sort { $hash{$b}{$all} <=> $hash{$a}{$all} } keys %hash){
  13.     print "$source = $hash{$source}{$all}\n";
  14.     for my $dest (sort {$hash{$source}{$b} <=> $hash{$source}{$a}} keys %{$hash{$source}}){
  15.         print "$source => $dest $hash{$source}{$dest}\n";
  16.     }
  17. }




阅读(1521) | 评论(0) | 转发(0) |
0

上一篇:array in hash value

下一篇:debugger perl -d

给主人留下些什么吧!~~