ディレクトリ内のファイル名取得chdir ディレクトリのパス; $filecnt = 0; #ファイル数カウンタ(総ファイル数) opendir(DIR, '.'); while(defined($dir = readdir(DIR))){ unless($dir eq "." || $dir eq ".."){ print("$dir\n"); $filecnt++; } } print("ファイル数は$filecnt\n"); closedir(DIR);