Re: [問題] 讀取檔案的內容

看板Perl作者 (dryman)時間12年前 (2012/11/14 09:51), 編輯推噓1(101)
留言2則, 1人參與, 最新討論串10/10 (看更多)
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)

11/14 21:37, , 1F
感謝您~不過我將split(/:\s|,改成split(/\s|,才可正常輸出
11/14 21:37, 1F

11/14 21:38, , 2F
就有抓到我要的值了~
11/14 21:38, 2F
文章代碼(AID): #1GelaM-k (Perl)
文章代碼(AID): #1GelaM-k (Perl)