in reply to Re^2: no size with stat and lstat in windows
in thread no size with stat and lstat in windows
Anyway, check this modified version of your code:
Note that the full path to the file to use with -d , -e , or lstat() is the combination of the directory path plus the filename returned from readdir().use File::Spec; my $dir = "c:\\Perl"; opendir DIR, $dir or die $!; foreach my $file (readdir(DIR)){ my $path_to_file = File::Spec->catfile( $dir, $file ); printf " I see file '%s' path '%s'\n", $file, $path_to_file; next unless -e $path_to_file; unless(-d $path_to_file){ print $path_to_file; my @stats = lstat ($path_to_file); print "\t\$stat = $stats[7]\n"; } }
I used the File::Spec module to combine these because I'd rather let it worry about combining directory paths and filenames and getting the '/' or '\' separators correct.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: no size with stat and lstat in windows
by Scarborough (Hermit) on Sep 21, 2004 at 12:42 UTC |