#! perl -slw use strict; use threads; sub worker { my( $dir ) = @_; my $total = 0; opendir my $dh, $dir or die "$dir : $!"; while( my $file = readdir $dh ) { $total += -s "$dir/$file"; } closedir $dh; return $total; } my @threads; for my $dir ( @ARGV ) { if( -d $dir ) { push @threads, threads->new( \&worker, $dir ); } } my $total; $total += $_->join for @threads; print "Total bytes in files in directories [@ARGV] is: ", $total; __END__ C:\test>612156 3 4 5 data Total bytes in files in directories [3 4 5 data] is: 654203874