作者dryman (dryman)
看板Perl
标题Re: [问题] 读取档案的内容
时间Wed Nov 14 09:51:15 2012
my %total;
open (RESULT , "<". $result_file);
while(<RESULT>)
{
my ($check, $num, undef, $kind, undef, $qty) = split(/:\s|, /,$_);
$total{ $num } += $qty if $check =~ /Number/;
}
close (RESULT);
print "代号: $_, total: $total{ $_ }\n" for sort keys %total;
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.109.16.166
※ 编辑: dryman 来自: 140.109.16.166 (11/14 09:53)
1F:推 hws110:感谢您~不过我将split(/:\s|,改成split(/\s|,才可正常输出 11/14 21:37
2F:→ hws110:就有抓到我要的值了~ 11/14 21:38