Unfortunately, since I rarely (if ever) code Perl under Windows, I may not have an immediate advice to cure your problem. However, I still think you don't have to do the '-f' check inside your
wanted subroutine. My thinking is that the file (
$File::Find::name) should always exist, hence the reason it was found in the first place.
As to why you are getting the "Can't call method 'size' on an undefined value" error, it seems as if the stat() function fails to obtain file statistics due to reasons such as certain file attributes (hidden, archive, etc.)? If you are working on WindowsNT there also might be some conflicting group/user permissions at play.
To shield yourself from the error, you might consider adding this check:
....
if (my $file_stat = stat($File::Find::name)) {
$wanted_count[$i] += $file_stat->size;
} else {
print "Failed to obtain stats on file '$File::Find::name'";
}
return;
.....
|
"There is no system but GNU, and Linux is one of its kernels." -- Confession of Faith
|