#Lets assume that the locations will be passed like: c:/progra~1/apache~1/apache2/htdocs/a_error1 c:/progra~1/apache~1/apache2/htdocs/a_error2 into an array @local_list; #Open directory and search for *.TXT files my(@dircontent, $filesize, $file); for my $path(@local_list) { opendir my $dirh,$path or die "Can't open $path"; push (@dircontent,grep { /\.txt$/ } readdir($dirh)); closedir($dirh) or die "Can't close $path"; } #After finding all the text files I need to get the file names and it's size and print it out, but I am loosing value after the first file, why? my $list_count=-1; foreach my $file (@dircontent) { $list_count++; $filesize = -s $file; print "
L123 - $list_count - The file name: $file is $filesize bytes long.
\n\n"; #exit; }