Re: [问题] 读取档案的内容

楼主: dryman (dryman)   2012-11-14 09:51:15
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;
作者: hws110 ( only you )   2011-01-14 21:37:00
感谢您~不过我将split(/:\s|,改成split(/\s|,才可正常输出就有抓到我要的值了~

Links booklink

Contact Us: admin [ a t ] ucptt.com