--- [EMAIL PROTECTED] wrote: > Take a look at File::Find.
Hi Craig. Here is a little more to get you started. It is certainly not complete but may help. [Tested on win98se and build 521.] Mind the line wrap. # ---------- # starting with a given dir, # subtotal all files by extension, # for the dir and subordinate dirs. use strict; use File::Find; my $dir = 'c:/_/linux/bu/apache/html/'; # CHANGE THIS #my $dir = 'c:/_/perl/test/tee_output/'; open(MX, ">mx.txt") || die "opening mx.txt. $!"; my @f = &get_full_path_of_files( $dir ); foreach (@f) { print MX "$_\n"; } my %sizes = &get_ext_sizes( @f ); foreach ( keys %sizes) { print MX "$_\t", '->', "\t$sizes{$_}\n"; } print MX "\n"; %sizes = reverse %sizes; foreach ( sort {$a <=> $b} keys %sizes) { print MX "$_\t", '->', "\t$sizes{$_}\n"; } #print MX "\n"; close(MX); # ----- just subroutines below here. sub get_ext_sizes { my @files = @_; my ( $size, %exts, $ext, ); foreach my $file ( @files ) { if ( $file =~ /.*\.(.+)?/ ) { # file ext with one or more chars $ext = lc $1; # print " ext: $ext\n"; $size = (stat($file))[7]; # print "size: $size\n"; if ( defined $exts{$ext} ) { $exts{$ext} += $size; } else { $exts{$ext} = $size; } # print "cuml: $exts{$ext}\n"; } # elsif ( ... ) { # file ext, no chars } # elsif ( ... ) { # other } } return %exts; } sub get_full_path_of_files { my @temp; # save fullpath to array. find (\&wanted, $dir ); sub wanted{ -f and push @temp, "$File::Find::name" } return sort @temp; } # ---------- --- Jim __________________________________________________ Do You Yahoo!? Send FREE video emails in Yahoo! Mail! http://promo.yahoo.com/videomail/ _______________________________________________ Perl-Unix-Users mailing list. To unsubscribe go to http://listserv.ActiveState.com/mailman/subscribe/perl-unix-users