in reply to File Size in Directory

Problem is $local_list[$list_count] in your print line ... @local_list only has 2 elements, but $list_count is in the range 0 ... $#dircount ... Root issue is that you need to keep track of what directory you found each file in ..

One way to solve this is just do it all at once:
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( '<br><b>L123 - %d - The file name: <a href="../../%s/%s">%s</a>< +/b> is <font color=red>%d</font> bytes long.<br>' . "\n\n", $i, $path, $file, $file, -s $file ; } }
Otherwise you need a data structure other than just @dircontent ...

Also of interest might be File::Find and File::Find::Rule ...

Update: a File::Find::Rule (and File::Basename) solution:
use File::Find::Rule; use File::Basename; my @files = File::Find::Rule->file() ->name( '*.txt' ) ->maxdepth(1) ->in( @local_list ) ; foreach my $i (0..$#files){ my $file = $files[$i]; printf '<br><b>L123 - %d - The file name: <a href="../../%s">%s</a></b> + is <font color=red>%d</font> bytes long.<br>' . "\n\n", $i, $file, basename($file), -s $file, ; }