[問題] 問題請教
最近開始使用Perl來處理研究上的計算,
寫了如下的程式:
--------------------------------------------------------------------------
use Cwd;
$dir=cwd;
open inf, "<$dir/RT.txt";
open out1, ">$dir/RT_output1.txt";
open out2, ">$dir/RT_output2.txt";
while(<inf>){
chomp;
@A=($mw, $seq)=split/\s+/;
print out1 "$seq\n";
foreach $seq(@A){
%h = ( W=> 11.0, F=> 10.5, L=> 9.6, I=> 8.4, M=> 5.8,
V=> 5.0, Y=> 4.0, A=> 0.8, T=> 0.4, P=> 0.2,
E=> 0.0, D=> -0.5, C=> -0.8, S=>-0.8, Q=> -0.9,
G=>-0.9, N=>-1.2, R=>-1.3, H=>-1.3, K=>-1.9 );
$sum+=$h{$_} for split//, $seq;
}
print out2 "$seq $sum\n";
}
close inf;
close out1;
close out2;
-------------------------------------------------------------------------
分成out1和out2只是為了檢查,
在output2裡的數值為何會是從上一列累計的啊?
問題是不是出在foreach那邊呢?
另外我想要計算的只有英文字串的部份,
該如何略過RT檔案裡的第1,4,5列呢?
附上RT.txt: http://www.badongo.com/file/7263659
煩請前輩們指點一下,
謝謝!!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 203.187.45.149
→
01/12 16:05, , 1F
01/12 16:05, 1F
推
01/12 16:13, , 2F
01/12 16:13, 2F
→
01/12 16:15, , 3F
01/12 16:15, 3F
→
01/13 23:29, , 4F
01/13 23:29, 4F
→
01/13 23:30, , 5F
01/13 23:30, 5F
→
01/14 01:59, , 6F
01/14 01:59, 6F
→
01/14 10:56, , 7F
01/14 10:56, 7F
→
01/14 13:06, , 8F
01/14 13:06, 8F
→
01/14 13:06, , 9F
01/14 13:06, 9F
→
01/14 13:08, , 10F
01/14 13:08, 10F
→
01/14 13:08, , 11F
01/14 13:08, 11F
→
01/14 13:22, , 12F
01/14 13:22, 12F
→
01/14 13:23, , 13F
01/14 13:23, 13F
→
01/14 15:20, , 14F
01/14 15:20, 14F
→
01/14 15:21, , 15F
01/14 15:21, 15F
→
01/14 21:11, , 16F
01/14 21:11, 16F
→
01/14 21:13, , 17F
01/14 21:13, 17F
→
01/14 21:52, , 18F
01/14 21:52, 18F
→
01/14 21:53, , 19F
01/14 21:53, 19F
→
01/15 17:11, , 20F
01/15 17:11, 20F
討論串 (同標題文章)
Perl 近期熱門文章
PTT數位生活區 即時熱門文章