hello there, i have some code that i use to reach out to a list of directory's to count how many files are in those directory. it comes back working fine, but i wanted to change it around so that the numbers coming back from the folder counts could be added together so i can get a total, and i' can't seem to figure out how to get the total into something where i can add all the returns together. i thought that pushing the numbers coming from the counting process as it goes into each row would work, but that doesn't seem to do it.
push (@finalcount, @fileslist);
$filecount = @finalcount;
#!/usr/bin/env perl
use File::Find;
use File::Copy;
use Mail::Sender;
use Net::SMTP;
use File::Basename;
use File::Slurp;
use POSIX qw(strftime);
my $date = strftime("%m-%d-%y",localtime);
my $time = strftime("%I:%M:%S",localtime);
chomp($myname = `id -un`);
BEGIN { unshift @INC, '/usr/bin/lib' }
my $findme = "/Volumes/photorepos/Perl/HAL/WorkLoad/";
my $count = "/Users/$myname/Desktop/count.txt";
my $log = "> $count";
chdir($findme) or warn "/Volumes/photorepos/Perl/HAL/WorkLoad/ $!";
####################################
#Open the file made above and the list of files to search for
####################################
print "$date $time Reporting Running\n";
my $filename = 'directorys.txt';
# my $currentfiles = '/Users/flieckb/Desktop/count.txt';
open(my $fh, '<:encoding(UTF-8)', $filename)
or die "Could not open file '$filename' $!";
open FILE, "$log" or warn $!;
while (my $row = <$fh>) {
chomp $row;
foreach ($row) {
chdir ($row);
(@fileslist) = glob "*";
if ( -e "Thumbs.db") {
unlink ("Thumbs.db") or print "thumbs.db $!\n";
}
$filecount = @fileslist;
if (@fileslist > 0) {
# if (-d "$row"){
print FILE "$filecount\n";
push (@finalcount, @fileslist);
$filecount = @finalcount;
# print "total $finalcount\n";
# foreach $file (@fileslist) {
# print("$file\n");
# }
}
# }
else
{
# print "$row\t0\n"
}
}
}
close ;
# sub us {
# system "/Volumes/photorepos/Perl/HAL/WorkLoad/CurrentEmailSender.pl"
+;
# }
# us();