in reply to Re: Re: Re: Stumped with File::Find and -s
in thread Stumped with File::Find and -s

Getting closer: As I stated above the code results in a value of 5856. However I just discovered if I remove the + sign from the += I get the value of the last file uploaded.
use File::Find; my $total_size = 0; find(sub { $total_size = -s }, $upload_dir );
For example I upload 4 files of 441, 441, 439, 439 bytes. The result without the + is 439 bytes. Can you shed any light on this??? Bob

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Stumped with File::Find and -s
by BrowserUk (Patriarch) on Nov 24, 2002 at 17:18 UTC

    Suggestion: Modify the find in the following way. This will cause the names and sizes of the files found to be printed to STDERR. If you run your script locally from the command line and redirect STDOUT to a file or the null device, then you will see exactly what files are being found and sized.

    find(sub { print STDERR $_, -s, $/; $total_size = -s }, $upload_dir );

    If you have to run this remotely, the output should become part of your webserver log file. Take a look and see what files are being found, that should help you isolate the problem.


    Okay you lot, get your wings on the left, halos on the right. It's one size fits all, and "No!", you can't have a different color.
    Pick up your cloud down the end and "Yes" if you get allocated a grey one they are a bit damp under foot, but someone has to get them.
    Get used to the wings fast cos its an 8 hour day...unless the Govenor calls for a cyclone or hurricane, in which case 16 hour shifts are mandatory.
    Just be grateful that you arrived just as the tornado season finished. Them buggers are real work.

      Hello, I ran as you said. The values listed below.
      .4096 BandWPainting1.htm441 BandWPainting2.htm441 ColorPainting1.htm43 +9 ColorPainting2.htm439
      The 441+441+439+439 = 1760, which is what I am looking for. The 4096 + 1760 = 5856. is the erroneous value I reported. Is the '.' mean it is reading the hidden area?

        . represents the current directory. The size of the directory is usually a fixed amount, on your system its 4096 bytes. To fix your problem, substitute this line.

        find(sub { $total_size += -s if -f }, $upload_dir );

        Please also read perlfunc:_X.


        Okay you lot, get your wings on the left, halos on the right. It's one size fits all, and "No!", you can't have a different color.
        Pick up your cloud down the end and "Yes" if you get allocated a grey one they are a bit damp under foot, but someone has to get them.
        Get used to the wings fast cos its an 8 hour day...unless the Govenor calls for a cyclone or hurricane, in which case 16 hour shifts are mandatory.
        Just be grateful that you arrived just as the tornado season finished. Them buggers are real work.