foreach my $path ( @local_list ){ opendir my $dirh,$path or die "Can't open $path"; my @files = grep { /\.txt$/ } readdir($dirh); closedir($dirh) or die "Can't close $path"; foreach my $i (0..$#files){ my $file = $files[$i]; printf( '
L123 - %d - The file name: %s is %d bytes long.
' . "\n\n", $i, $path, $file, $file, -s $file ; } }