#!/usr/bin/perl -w #!C:\Perl\bin\perl -w my $directory='C:\dev\perl'; my $size=0; my $file; #opendir(DIRHANDLE, $directory) or die "couldn't open $directory : $!\n"; #my@files = grep(!/^\.\.?$/,readdir(DIRHANDLE)); push(@dirs,$directory); # add INITIAL directory to an array foreach $dir (@dirs) # loop through the elements of an array { opendir(DIR,"$dir") || die "opendir $dir failed"; my@list = grep(!/^\.\.?$/,readdir(DIR)); closedir(DIR); foreach $file (@list) { if (-d "$dir/$file") { push(@dirs, "$directory/$file"); # if this is a dir add it to an array } if (-f "$dir/$file") { # only if it a file do your size stuff $size=(-s "$dir/$file"); print "$dir,$file,$size"; print "\n"; } } }; #closedir(DIRHANDLE);