in reply to Re: File::Find stat question
in thread File::Find stat question

Alternatively, do the stat on $File::fin­d::name

Actually, you want to do the stat on $_. In typical usage, File::Find has chdir'd into "sub/dir" and found "file.foo" and thus has set $_ to "file.foo" and set $File::Find::name to "sub/dir/file.foo". So doing stat on $File::Find::name will usually fail (once you've gone at least one subdirectory deep).

- tye        

Replies are listed 'Best First'.
Re^3: File::Find stat question ($_)
by Anonymous Monk on Nov 24, 2014 at 03:23 UTC

    Thanks for your advice, however it still won't work I'm getting 0 printed for

    # How big is it? my $fsize = (stat($_))[7]; push @sfiles, $fsize; print "$fsize\n";

    Also instead of a 1MB file I'm getting a 700! MB file with this bit... so something isn't right at all :-(

    foreach my $p (@allpathlisting) #Foreach line (path found) $p in the a +rray @allpathlisting { #Write each line in the array to Paths.bak print LIST "$p\n"; foreach my $s (@sfiles) { print LIST "$s\n"; } }