Perl - How to count the sum in bytes of all the files contained in a folder?
my($totalBytes) = 0; while(<STDIN>) { my($line) = $_; chomp($line); if($line !~ /<DIR>/) #directories don't count { #*** only lines with dates at position 28 **** if ($line =~ /.{12}((\d| |,){14}) \d\d-\d\d-\d\d/) { my($bytes) = $1; $bytes =~ s/,//; #substitute nothing for comma -- delete commas $totalBytes += $bytes; } } } print "$totalBytes bytes in directory.\n";