下のように$aaaというディレクトリの中にあるファイルとディレクトリを分けて表示するのがうまくいきません
windows環境です

opendir(D,$aaa);
@files = readdir(D);

foreach $file(@files){

if(-d $file){
print "ディレクトリ=$file<BR>";
}
if(-f $file){
print "ファイル=$file<BR>";
}
}
closedir(D);

windowsでも分けて表示できる方法ってありますか?
できればモジュールは使わないでできる方がいいです。