1. 程式人生 > 其它 >perl獲取指定資料夾下檔名

perl獲取指定資料夾下檔名

技術標籤:指令碼

第一種方法:
這種只能獲取當前資料夾下檔名
在這裡插入圖片描述
第二種方法借用 ls 命令
這種方法麻煩點,但實用

unlink "name_list.log";
system "touch name_list.log";

system "ls $dir_path >> name_list.log";
$list = "name_list.log";
open (IN_DIR,"$list");
while($line = <IN_DIR>){
        chomp(
$line); push @list_array , $line; } foreach $list_array (@list_array){ ............. ........... ...... }

第三種方法:

通過readdir 獲得,但會把資料夾下根目錄資料夾一併輸出