如何用perl讀取資料夾下的大量首列相同的tt文

2021-12-16 12:02:12 字數 654 閱讀 1137

1樓:匿名使用者

opendir d,"1" or die $!; #把所有txt檔案都放到一個叫1的資料夾中

@array=grep(/\.txt/,readdir d);

foreach $list(@array)}foreach(@new)

2樓:自由de王國

二維陣列

把每個檔案的每一行split成兩個元素,然後把第二個元素(也就是第二列的資料)加到二維陣列中,並且保證不同檔案中行數相同的列在同一個子陣列中(說的有點繞,希望你懂)。輸出的時候直接用換行符join

3樓:白堊紀屠龍英雄

目錄 :/dir/

檔案:a1.txt,a2.txt,a3.txt...an.txt**:$files = globe("/dir/*.txt");

%res

foreach $file($files);//嚴謹點加個undef判斷吧,懶得寫了

push(@array,$value);

$res = @array;

undef @array;}}

$out = io::file->new(">res.txt")foreach $key (keys(%res)))."\n");

}供參考

linu如何把各資料夾下的tt檔案copy到另檔案

find mnt disk?flume test huatong picture 20140116 9 type f name txt exec cp opt test 既然目錄只是disk1,disk2,disk3,disk4,disk5的區別,那麼用萬用字元表示就可以 disk?cp 不帶引數,...

window資料夾下的隱藏檔案怎麼檢視

dir ah 列出隱藏檔案 dir c windows ah 列出 window資料夾下 所有隱藏檔名 和 日期 檔案大小 等 dir c windows ah b 只 列出所有隱藏 檔名 你可以 用 dir c windows ah b my.log 命令轉向 存入 my.log 檔案,以後可以用...

win7,如,何設定檔案屬性,怎樣隱藏資料夾下方的檔案屬性

1 首先,在設定檔案屬性之前,要準備好目標檔案,大家可自行選擇相應檔案。2 準備好目標檔案後,開啟 易語言 程式,新建 windows視窗程式 並進入 windows視窗程式 設計介面。3 在已建立好的 windows視窗程式 的介面上,繪製標籤元件 編輯框元件 拖放物件及按鈕元件各一個,還有,四個...