I seem to remember seeing this question or something very, very similar to it in the recent past. I can't be 100% sure, but if you are the same anon Monk, then please pay attention when you get replies.

1)Always use strict; and use warnings;. Even on Windows, #!/usr/bin/perl -w is equivalent to use warnings; although the path to Perl is ignored.
2)File::Find will visit all files and directories underneath the starting directory. There is no need to save the directories and then re-open them only to read the files names yet again. All of those file names and the directory have already been visited!
3)If what you need to do to the file is not complicated, do it right in the File::Find subroutine - No need to save it's path and come back.
4) Please pay more attention to the indenting of your code - it is important.
5) I think the code below is essentially equivalent to what your code does, reports zero length files that are found.
6) I was not able to understand your question about what you want to do other than this. "But instead of simply generating a log file..." Please try a different explanation.

#!/usr/bin/perl -w use strict; use File::Find; use File::Basename; my $start_dir = "C:/temp"; my $log_file = 'C:/temp/logfile.txt'; open (my $log, '>', $log_file) or die "cannot open $log_file for write +"; find (\&process_file, $start_dir); sub process_file { return unless -f; # do not process directories, # only "real files" my $full_path_name = $File::Find::name; print "$full_path_name\n"; #other ways of writing the "if", but extending your code if ( -s == 0 and ($_ ne 'empty.txt') and ($_ ne 'sample.txt') and ($full_path_name ne $log_file) ) { print $log "Warning: $full_path_name has size ZERO\n"; } }

In reply to Re: Perl Log File Help by Marshall
in thread Perl Log File Help by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.