zoukankan      html  css  js  c++  java
  • perl 求值

    node2:/root#cat sum.pl 
    open (my $fh,'<','aaa')  or die$!;
    while (<$fh>){
          $count++;
          print $count."
    ";
          my $a=(split(/s+/,$_))[1];
          print $a."
    ";
          $b=$b+$a;
    };
    print "----------------------------
    ";
    print $b."
    ";
    print "----------------------------
    ";
    
    node2:/root#cat aaa
    a 13
    b 23
    c 3
    d 9
    e 10
    node2:/root#perl sum.pl 
    1
    13
    2
    23
    3
    3
    4
    9
    5
    10
    ----------------------------
    58
    ----------------------------
    
    
    node2:/root#cat sum.pl 
    open (my $fh,'<','aaa')  or die$!;
    while (<$fh>){
          $count++;
          print $count."
    ";
          my $a=(split(/s+/,$_))[1];
          print $a."
    ";
          $b=$b+$a;
    };
    print "----------------------------
    ";
    print $b."
    ";
    print "----------------------------
    ";
    print "平均值
    ";
    print $b/$count."
    ";;
    print "平均值
    ";
    node2:/root#perl sum.pl 
    1
    13
    2
    23
    3
    3
    4
    9
    5
    10
    ----------------------------
    58
    ----------------------------
    平均值
    11.6
    平均值

  • 相关阅读:
    Android中ProgressBar显示小数的方法
    Android屏幕适配-安卓切图
    android -services
    Java 位移运算符
    异常、集合、数据结构
    常用类
    编码
    String类
    Android-1
    ButterKnife注解式绑定控件
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349267.html
Copyright © 2011-2022 走看看