in reply to File Size in Directory
Otherwise you need a data structure other than just @dircontent ...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 ; } }
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, ; }
|
|---|