in reply to Complete Directory+Depth Listing
you don't check the return status of stat. If $File::Find::name is a broken link, stat may fail (it does on my system) and you get the following error:my $file_info = stat($File::Find::name); $dirs{$File::Find::dir}{size} += $file_info->size;
As a general rule of thumb, you should always check the return value of things that might fail (which includes almost any call related to the file system). It might also be possible to break this with a race condition where $File::Find::name was deleted prior to the stat.Can't call method "size" on an undefined value at ./files.pl line 50.
|
|---|