neilwatson has asked for the wisdom of the Perl Monks concerning the following question:
find(\&offenders, $dir); sub offenders{ # do not include links return if (-l); # owner of file but skip # if owner is not a user # (uid < 500) $uid = (lstat($_))[4]; #return if ($uid < 500); if ($uid < 500){ print "UID is $uid, skipping $File::Find::dir $_\n"; return; } # scan only regular files if (-f){ $uname = getpwuid $uid; # gather name of file $fname = $File::Find::name; # size of file (kb) $size = (lstat($_))[7]; $size = int($size/1000); # keep running total of each # user's space use $size{$uname} += $size; } }
This code will skip files but not whole directories. What I have done wrong?
Neil Watson
watson-wilson.ca
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: File::find and skipping directories
by Paladin (Vicar) on Jun 01, 2004 at 20:24 UTC | |
|
Re: File::find and skipping directories
by cosimo (Hermit) on Jun 01, 2004 at 20:25 UTC | |
|
Re: File::find and skipping directories
by sacked (Hermit) on Jun 01, 2004 at 20:28 UTC | |
|
Re: File::find and skipping directories
by graff (Chancellor) on Jun 02, 2004 at 03:00 UTC | |
|
Re: File::find and skipping directories
by neilwatson (Priest) on Jun 02, 2004 at 13:41 UTC | |
by sacked (Hermit) on Jun 03, 2004 at 15:49 UTC |