#!/usr/bin/perl $block = ""; $dir= '.'; opendir DIR, $dir or die "Can't open directory $dir: $!\n"; while ($subdir= readdir DIR) { $dirtoget = "/var/www/html/Chinese/Language/$subdir"; if (opendir(SUBDIR, $dirtoget)){ while($subfile = readdir SUBDIR ){ if ($subdir ne "Picture" && $subdir ne "." && $subdir ne ".." && $subfile ne "." && $subfile ne ".."){ $block .= $subdir . " " . $subfile . " " . $subdir . "/" . $subfile ."\n";} } closedir(SUBDIR); } } closedir(DIR); open(DAT,">/var/www/html/php/checksound/sounddir.txt") || die("Cannot Open File"); print DAT $block; close(DAT);