if statement - Perl, how to choose a directory -
i'm trying determine of content of folder directory , file, wrote following result not expect:
opendir dh, $dir or die "cannot open dir: $!"; @dirs = grep !/^\.\.?$/, readdir dh ; foreach $files (@dirs) { print $files."<br>"; if ( -d $files ) { print $files." directory<br>"; } } closedir dh;
the result example below:
.file1 file.log file3.zip file4 file5.zip dir1.name1.suffix1.yyyy.mm.dd.hh.mm.ss file5.zip file6.tar dir2 dir3.name1.suffix1.yyyy.mm.dd.hh.mm.ss
where item starting dir actual directory, question why if failing discover them such? doing wrong?
$dir
is missing...
if ( -d "$dir/$files" ) { print $files." directory<br>"; }
Comments
Post a Comment