It's very cold, and my head hurts, so I can't quite parse the purpose of the program. But I can help you make it much simpler and shorter, and more correct (with strictures).

To follow your general program logic, but with the help of File::Find::Rule and File::DosGlob, the latter of which is a core module:

#!perl use strict; use warnings use autodie; # errors with open, chdir, etc are now fatal use File::Find::Rule; use File::DosGlob 'glob'; my $search = shift || 'c:/Documents and Settings/user/Desktop/newbatch +2' ; my $outfile = 'c:/Documents and Settings/user/Desktop/newbatch/log.txt +'; open my $outf, '>', $outfile; for my $dir (File::Find::Rule->dir->in($search)) { for my $file ( <*>) { my $path = "$dir\\$_"; print " $path\n"; if (-f $path) { if ($file ne 'empty.txt' and $file ne 'sample.txt') { unless (-s $path) { print $outf "Warning: $path has size ZERO\n"; } } } } }

OR, to be more concise:

#!perl use strict; use warnings; use autodie; use File::Find::Rule; use File::DosGlob 'glob'; my ($search) = @ARGV or die "need a directory to search"; sub found { my ($name, $path, $full) = @_; warn "Warning: $full has size ZERO" # outputs to STDERR unless $name ~~ ['empty.txt', 'sample.txt']; # Perl v5.10+ # unless $name eq 'empty.txt' or $name eq 'sample.txt'; } File::Find::Rule->file->empty->exec(\&found)->in($search);

In reply to Re: Perl Log File Help by Anonymous Monk
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.