in reply to File::Find stat question

Try doing the stat *before* you edit the path name into something that *nix doesn't understand....

(Alternatively, do the stat on $File::find::name instead of $fn.)

...roboticus

When your only tool is a hammer, all problems look like your thumb.

Replies are listed 'Best First'.
Re^2: File::Find stat question ($_)
by tye (Sage) on Nov 24, 2014 at 01:52 UTC
    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        

      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"; } }