neilwatson has asked for the wisdom of the Perl Monks concerning the following question:
# get file information sub offenders{ # scan only regular files if (-f){ # owner of file but skip # if owner is not a user # (uid < 500) $uid = (lstat($_))[4]; unless ($uid < 500){ $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; } } }
It seems that -f (plain file) will also count symlinks or perhaps it is following symlinks to directories. I would like the script to not count any symlinks. I tired if (-f && !-l) but that did not seem to make any difference. I also tried find(\&offenders, $dir, follow_skip=>2); but that did not seem to work either. What have I missed?
Ack! There is no problem after all. Normally, the directories I check are only used by one person. The users created a shared directory. In this directory are the extra files which caused the unexpected readings. Thus the script is fine. Sorry to have bothered you all.
Neil Watson
watson-wilson.ca
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: FIle::Find and skipping links
by Fletch (Bishop) on May 04, 2004 at 15:07 UTC | |
|
Re: FIle::Find and skipping links
by sgifford (Prior) on May 04, 2004 at 16:19 UTC |