Hello All
I have a script below that lists a directory tree structure (thanks for the base code
Jan!)and have modified it, unsuccessfully, to add the file size.
What have i done wrong ??
The output I am looking for is:
c:\anydir\foo.txt 1,102
code:
# Reads a directory tree and parses the results
# use strict;
use File::Find;
use File::stat;
use Cwd;
print STDOUT "Enter the root of the path to be evaluated: ";
$rootpath = <STDIN>; #path to be evaluated
chomp $rootpath; #delete the trailing newline
$dir = $rootpath;
print "Listing of $dir\n";
find ( sub { print qq{$File::Find::name\n};
$size=(stat($File::Find::name))[7];
printf "size is %04o\n", $size;
}, $dir );