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