获得Perl的平均值 [英] getting a average value in Perl

查看:85
本文介绍了获得Perl的平均值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此输入数据中有4个字段。我想获得第2/3/4列的平均值。如果你注意到,磁盘c53t2d6和c12t10d4发生了两次......所以我需要得到它们的平均值。如果它只出现一次,那么就把它当作平均值。


c42t3d0 0.01 0.00 1.19

c53t2d6 2.00 3.4 1.76

c12t10d4 0.01 0.00 1.42

c53t2d6 0.03 0.00 0.59

c12t10d4 0.02 0.00 0.82

提前谢谢。我一直在敲我的头3天......但没有运气..不知道如何构建它..



Jewsco

There are 4 fields in this input data. I want to get the average value for the column 2/3/4th. If you notice, disk c53t2d6 and c12t10d4 occured twice..so i need to get an average for them. If it occured only once, then just get take it as an average.

c42t3d0 0.01 0.00 1.19
c53t2d6 2.00 3.4 1.76
c12t10d4 0.01 0.00 1.42
c53t2d6 0.03 0.00 0.59
c12t10d4 0.02 0.00 0.82

THanks in advance. I been banging my head for a 3 days now..but no luck..Don''t know how to structure it..


Jewsco

推荐答案

这一切都很好,但是你制作了什么代码?我们需要先了解你的尝试才能帮助你。


问候,


杰夫
That''s all well and good, but what code have you produced? We need to see what you have tried before we can help you with it.

Regards,

Jeff

我在想一个哈希,以cXXXXX字符串作为键,数组引用作为值,数组包含其后面的数字。那么,计算平均值相当容易。它需要一些调整,但我相信你能做到。
I''m thinking a hash, with the cXXXXX string as the key and an array reference as the value, with the array containing the numbers following it. Calculating the average, then, is fairly easy. It''ll take some tweaking, but I''m sure you can do it.



我在想哈希,以cXXXXX字符串作为键,数组引用作为值,数组包含其后的数字。那么,计算平均值相当容易。它需要一些调整,但我相信你能做到。
I''m thinking a hash, with the cXXXXX string as the key and an array reference as the value, with the array containing the numbers following it. Calculating the average, then, is fairly easy. It''ll take some tweaking, but I''m sure you can do it.



我同意。

I agree.


这篇关于获得Perl的平均值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆