1 use strict; 2 use warnings; 3 use Cwd; 4 my $dir = 'd:\www'; 5 chdir($dir); 6 opendir DIR, $dir or die "Cannot open dir:$! "; 7 my %result; 8 while(my $filename = readdir(DIR)){ 9 next if (($filename eq '.') or ($filename eq '..')); 10 if(-d $filename){$result{$filename} = "Is dir";next;} 11 my $byts = -s $filename; 12 $result{"$filename"} = $byts."byts"; 13 } 14 while((my $key, my $value) = each %result){ 15 print "$key => $value "; 16 }