use File::Find; my $size; find(sub { $size += -s _ if -f }, $TargetPath);