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();

In reply to pushing file counts for adding by flieckster

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.