小時代5-perl對檔案按列排序

來源:互聯網
上載者:User

標籤:style   blog   http   color   ar   for   檔案   資料   div   

perl中經常有會遇到處理CSV格式的檔案,這樣的檔案類似二維數組,因此實際上的操作時對二維數組的操作了。
對這樣的行列表格,我們常常需要按照某列,或者先按照某列,再按另一列進行排序,具體的操作可以看一下下面的實現:

  1.  
  2. #!/usr/bin/perl
  3. my @line;
  4. while(<>)
  5. {
  6.   chomp;
  7.   push @line, [ split ];
  8. }
  9. foreach ( sort { $a->[0] <=> $b->[0] or $a->[1] <=> $b->[1] or $a->[2] <=> $b->[2] } @line)
  10. {
  11.   print @$_, "n";
  12. }

注意:
對於大的檔案,最好不要這麼用。
該指令碼會把資料全部搬到記憶體。

www.bbilo.com/gbdfzmzcwww.bbilo.com/gbdfbjlwww.bbilo.com/gbdfylyqwww.bbilo.com/mdgbdfrqrhwww.bbilo.com/gbdfmdyjmwww.bbilo.com/mdgbdfaqmwww.bbilo.com/gbdfkmdlwww.bbilo.com/gbdfxwzwww.bbilo.com/gbdfwtzxwww.bbilo.com/gbdfdmswww.bbilo.com/gbdfzcwww.bbilo.com/gbdfsywww.bbilo.com/gbdfwzxwww.bbilo.com/gbdfnyqbwww.bbilo.com/gbdfzjwww.bbilo.com/gbdfdzwww.jdcvv.com/gbdfylwwww.jdcvv.com/gbdfwww.jdcvv.com/gbdfkhwww.jdcvv.com/gbdfylwww.jdcvv.com/gbdfhykhwww.jdcvv.com/1659988_comgbdfwww.jdcvv.com/gbdfshywww.jdcvv.com/gbdfgwwww.jdcvv.com/gbdfwtwww.jdcvv.com/gbdfylcwww.jdcvv.com/gbdfdlwww.jdcvv.com/gbdfxcwww.jdcvv.com/gbdfyldlwww.jdcvv.com/gbdfylkhwww.jdcvv.com/gggbdfylcwww.jdcvv.com/gbdfsjzmdlwww.jdcvv.com/gbdfzmnyqwww.jdcvv.com/gbdfyjwww.jdcvv.com/gbdfxmfwww.jdcvv.com/szdmdgbdfwww.jdcvv.com/mdgbdfwww.jdcvv.com/gbdfdlkhwww.jdcvv.com/gbdfkh1581260www.jdcvv.com/gbdfylhbwzwww.jdcvv.com/gbdfyqwww.jdcvv.com/sygbdfylwww.jdcvv.com/gbdfylzmyqwww.jdcvv.com/gbdfylyflmwww.jdcvv.com/gbdfylcznlwww.jdcvv.com/gbdfwzwww.jdcvv.com/gbdftzwww.jdcvv.com/gbdfdhwww.jdcvv.com/gbdfsjwww.jdcvv.com/gggbdfwww.jdcvv.com/gbdfgfwwww.jdcvv.com/gbdfkhwwww.jdcvv.com/gbdfshwww.jdcvv.com/gbdfsjxzwww.jdcvv.com/gbdfylsjxzwww.jdcvv.com/gbdfwfmwww.jdcvv.com/gbdfdtkhwww.jdcvv.com/gbdfhywww.jdcvv.com/gbdfrhkhwww.jdcvv.com/gbdfzdlwww.jdcvv.com/gbdfwwww.jdcvv.com/gbdfdtkmdlwww.jdcvv.com/gbdfglwwww.jdcvv.com/gbdfxjwwww.jdcvv.com/gbdfwtkhzxwww.jdcvv.com/gbdfwtdhkhwww.jdcvv.com/gbdfwkhwww.jdcvv.com/gbdfwthykhwww.jdcvv.com/gbdftgywww.jdcvv.com/gbdfylwzwww.jdcvv.com/gbdfzmzcwww.jdcvv.com/gbdfbjlwww.jdcvv.com/gbdfylyqwww.jdcvv.com/mdgbdfrqrhwww.jdcvv.com/gbdfmdyjmwww.jdcvv.com/mdgbdfaqmwww.jdcvv.com/gbdfkmdlwww.jdcvv.com/gbdfxwzwww.jdcvv.com/gbdfwtzxwww.jdcvv.com/gbdfdmswww.jdcvv.com/gbdfzcwww.jdcvv.com/gbdfsywww.jdcvv.com/gbdfwzxwww.jdcvv.com/gbdfzjwww.jdcvv.com/gbdfdzwww.vqjqu.com/gbdfwww.vqjqu.com/gbdfkhwww.vqjqu.com/gbdfylwwww.vqjqu.com/gbdfylwww.vqjqu.com/gbdfhykhwww.vqjqu.com/1659988_comgbdfwww.vqjqu.com/gbdfdhtzwww.vqjqu.com/gbdfylptwww.vqjqu.com/gbdfshywww.vqjqu.com/gbdfzxkhwww.vqjqu.com/gbdfgwwww.vqjqu.com/gbdfwtwww.vqjqu.com/gbdfylcwww.vqjqu.com/gbdfdlwww.vqjqu.com/gbdfxcwww.vqjqu.com/gbdfyldlwww.vqjqu.com/gbdfkhblwww.vqjqu.com/gbdfylkhwww.vqjqu.com/gbylgbdfwww.vqjqu.com/gggbdfylcwww.vqjqu.com/gbdfsjzmdlwww.vqjqu.com/gbdfylflwww.vqjqu.com/gbdfzmnyqwww.vqjqu.com/gbdfyjwww.vqjqu.com/gbdfxmfwww.vqjqu.com/szdmdgbdfwww.vqjqu.com/mdgbdfwww.vqjqu.com/gbdfdhkhwww.vqjqu.com/gbdfdlkhwww.vqjqu.com/gbdfwtkhwww.vqjqu.com/gbdfkh1581260www.vqjqu.com/gbdfylhbwzwww.vqjqu.com/gbdfyqwww.vqjqu.com/sygbdfylwww.vqjqu.com/gbdfylzmyqwww.vqjqu.com/gbdfylyflmwww.vqjqu.com/gbdfylcznlwww.vqjqu.com/gbdfwzwww.vqjqu.com/gbdftzwww.vqjqu.com/gbdfdhwww.vqjqu.com/gbdfsjwww.vqjqu.com/gggbdfwww.vqjqu.com/gbdfgfwwww.vqjqu.com/gbdfkhwwww.vqjqu.com/gbdfshwww.vqjqu.com/gbdfylsjxzwww.vqjqu.com/gbdfwfmwww.vqjqu.com/gbdfhywww.vqjqu.com/gbdfzdlwww.vqjqu.com/gbdfwwww.vqjqu.com/gbdfdtkmdlwww.vqjqu.com/gbdfglwwww.vqjqu.com/gbdfxjwwww.vqjqu.com/gbdfwtkhzxwww.vqjqu.com/gbdfwtdhkhwww.vqjqu.com/gbdfwkhwww.vqjqu.com/gbdfwthykhwww.vqjqu.com/gbdftgywww.vqjqu.com/gbdfylwzwww.vqjqu.com/gbdfzmzcwww.vqjqu.com/gbdfbjlwww.vqjqu.com/gbdfylyqwww.vqjqu.com/mdgbdfrqrhwww.vqjqu.com/gbdfmdyjmwww.vqjqu.com/mdgbdfaqmwww.vqjqu.com/gbdfkmdlwww.vqjqu.com/gbdfxwzwww.vqjqu.com/gbdfwtzxwww.vqjqu.com/gbdfdmswww.vqjqu.com/gbdfzcwww.vqjqu.com/gbdfsywww.vqjqu.com/gbdfwzxwww.vqjqu.com/gbdfnyqbwww.vqjqu.com/gbdfzjwww.vqjqu.com/gbdfdzwww.ecbga.com/gbdfwww.ecbga.com/gbdfkhwww.ecbga.com/gbdfylwwww.ecbga.com/gbdfylwww.ecbga.com/gbdfhykhwww.ecbga.com/1659988_comgbdfwww.ecbga.com/gbdfdhtzwww.ecbga.com/gbdfylptwww.ecbga.com/gbdfshywww.ecbga.com/gbdfzxkhwww.ecbga.com/gbdfgwwww.ecbga.com/gbdfwtwww.ecbga.com/gbdfylcwww.ecbga.com/gbdfdlwww.ecbga.com/gbdfxcwww.ecbga.com/gbdfyldlwww.ecbga.com/gbdfkhblwww.ecbga.com/gbdfylkhwww.ecbga.com/gbylgbdfwww.ecbga.com/gggbdfylcwww.ecbga.com/gbdfsjzmdlwww.ecbga.com/gbdfylflwww.ecbga.com/gbdfzmnyqwww.ecbga.com/gbdfyjwww.ecbga.com/gbdfxmfwww.ecbga.com/szdmdgbdfwww.ecbga.com/mdgbdfwww.ecbga.com/gbdfdhkhwww.ecbga.com/gbdfdlkhwww.ecbga.com/gbdfwtkhwww.ecbga.com/gbdfkh1581260www.ecbga.com/gbdfylhbwzwww.ecbga.com/gbdfyqwww.ecbga.com/sygbdfylwww.ecbga.com/gbdfylzmyqwww.ecbga.com/gbdfylyflmwww.ecbga.com/gbdfylcznlwww.ecbga.com/gbdfwzwww.ecbga.com/gbdftzwww.ecbga.com/gbdfdhwww.ecbga.com/gbdfsjwww.ecbga.com/gggbdfwww.ecbga.com/gbdfgfwwww.ecbga.com/gbdfkhwwww.ecbga.com/gbdfshwww.ecbga.com/gbdfylsjxzwww.ecbga.com/gbdfwfmwww.ecbga.com/gbdfdtkhwww.ecbga.com/gbdfhywww.ecbga.com/gbdfrhkhwww.ecbga.com/gbdfzdlwww.ecbga.com/gbdfwwww.ecbga.com/gbdfdtkmdlwww.ecbga.com/gbdfglwwww.ecbga.com/gbdfxjwwww.ecbga.com/gbdfwtkhzxwww.ecbga.com/gbdfwtdhkhwww.ecbga.com/gbdfwkhwww.ecbga.com/gbdfwthykhwww.ecbga.com/gbdftgywww.ecbga.com/gbdfylwzwww.ecbga.com/gbdfzmzcwww.ecbga.com/gbdfbjlwww.ecbga.com/gbdfylyqwww.ecbga.com/mdgbdfrqrhwww.ecbga.com/gbdfmdyjmwww.ecbga.com/mdgbdfaqmwww.ecbga.com/gbdfkmdlwww.ecbga.com/gbdfxwzwww.ecbga.com/gbdfwtzxwww.ecbga.com/gbdfdmswww.ecbga.com/gbdfzcwww.ecbga.com/gbdfsywww.ecbga.com/gbdfwzxwww.ecbga.com/gbdfnyqbwww.ecbga.com/gbdfzjwww.ecbga.com/gbdfdzwww.urukw.com/gbdfwww.urukw.com/gbdfkhwww.urukw.com/gbdfylwwww.urukw.com/gbdfylwww.urukw.com/gbdfhykhwww.urukw.com/1659988_comgbdfwww.urukw.com/gbdfdhtzwww.urukw.com/gbdfylptwww.urukw.com/gbdfshywww.urukw.com/gbdfzxkhwww.urukw.com/gbdfgwwww.urukw.com/gbdfwtwww.urukw.com/gbdfylcwww.urukw.com/gbdfdlwww.urukw.com/gbdfxc

 

小時代5-perl對檔案按列排序

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.