看板 Perl 關於我們 聯絡資訊
如題 檔案格式(a.txt 分隔是tab) 如下 A 122 334 0.145 B 222 456 0.554 C 333 788 0.456 就是 我想對第三欄 sort 以下是我的寫法 my $set1 = shift; #a.txt open FH1,$set1 or die; while (<FH1>){ chomp; /^#/ and next; @_ = split /\t/; $test{$_[0]} = { contain => $_[1], total => $_[2], pvalue => $_[3] }; } for ( values %test) { print "$_->{pvalue}\n"; } 執行 ./play2.pl a.txt 輸出 0.145 0.554 0.456 ============== 請問要怎麼對第三欄排列? for (sort ($a <=> $b)第三欄){print "$_\n";} 這樣... 謝謝各位 -- -- ▂▂ ▂▂▂ ▂▄▅▅▄▆█ _█◣ ◢ (●) ◣/\\ 丫 │◥  ̄◤ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.116.215.174
sqrt1089:ps 有爬過文,現在也還再爬文中... 01/30 17:35
sqrt1089:thX 02/01 16:37
sintsu:用shell的sed運算就可以 02/17 00:29
sintsu:可參考 http://unstableme.blogspot.com/search/label/Awk 02/17 00:29