我有一個下面的修復文件,我想知道同時發送了多少個訂單。我使用標籤52作爲發送時間。如何計算散列值中發生的次數
下面是文件,
8 = FIX.4.2 | 9 = 115 | 35 = A | 52 = 20080624-12:43:38.021 | 10 = 186 |
8 = FIX.4.2 | 52 = 20080624-12:43:38.066 | 10 = 111 | 8 = FIX.4.2 | 9 = 105 | 35 = 1 | 22 = BOO | 52 = 20080624-12:43:39.066 | 10 = 028 |
如果我要計數標籤52值的相同發生次數是多少?我該如何檢查?
到目前爲止,我已經寫了下面的代碼,但沒有給我頻率。
#!/usr/bin/perl
$f = '2.txt';
open (F,"<$f") or die "Can not open\n";
while (<F>)
{
chomp $_;
@data = split (/\|/,$_);
foreach $data (@data)
{
if ($data == 52){
@data1 = split (/=/,$data);
for my $j (@data1)
{
$hash{$j}++;
} for my $j (keys %hash)
{
print "$j: ", $hash{j}, "\n";
}
}
}
}
數據文件中每對記錄之間是否真的有空行? – Borodin