#!c:\perl\bin\perl.exe -w use strict; use warnings; use diagnostics; use File::List; use Win32::Perms; my $search2 = new File::List("c:\\"); my @tree2 = @{$search2->find(".*")}; my %ownerhash = GetFilesByUser(@tree2); for my $key(sort keys %ownerhash) { print "$key $ownerhash{$key}{numbytes} bytes in $ownerhash{$key}{numfiles} files\n"; } exit; sub GetFilesByUser { my @dirtree = @_; my $file_obj; my $fileowner; my %temphash; for my $x (0..$#dirtree) { $dirtree[$x] =~ s/\//\\/g; $dirtree[$x] =~ s/\\\\/\\/g; $file_obj = new Win32::Perms($dirtree[$x]) || print "ERROR1: $!\nFILE: $dirtree[$x]\n"; if(not $file_obj) { $temphash{FILESTHATGOTERRORS}{numfiles} ++; $temphash{FILESTHATGOTERRORS}{numbytes} += -s $dirtree[$x]; } elsif($file_obj ne "1") { $fileowner = $file_obj->Owner() || print "ERROR2: $!\nFILE: $dirtree[$x] \n"; $file_obj->Close(); $temphash{$fileowner}{numfiles} ++; if(! -z $dirtree[$x]) #check to see if file is zero bytes { $temphash{$fileowner}{numbytes} += -s $dirtree[$x] || print "ERROR3: $!\nFILE: $dirtree[$x]\n"; } } } return %temphash; }