#!/usr/bin.perl -w use strict; use File::Find; my $byte_total; my $file_total; find (\&sum_bytes, "C:/temp"); sub sum_bytes { return() unless (-f $File::Find::name); $byte_total += -s _; # not a typo! # "_" different than "$_"! # see [id://951317] $file_total++; } print "total bytes in C:/temp: $byte_total in $file_total files\n"; # prints on my Windows system: # total bytes in C:/temp: 656201485 in 2554 files