Hi, I am using the below perl script to recursively read directories and sub directories and find out files which are of size zero and generate a log file for them. But instead of simply generating a log file I want to create e directories which it is reading and generate the log file in them. For example My script is reading the directory structure as
Directory1 -> Sub directory1 ->Folder1 -> files " " ->Folder2 -> files " " ->Folder3 -> files

Directory2 -> Sub directory2 ->Folder1 ->files " " ->Folder2 ->files

#!/usr/local/bin/perl use File::Find ; use File::Basename; $search = shift || 'c:\Documents and Settings\user\Desktop\newbatch2' +; $outfile = 'c:\Documents and Settings\user\Desktop\newbatch\log.txt'; open OUTF, "> $outfile" or die print " can't create logfile; $!"; find sub { push @dirs, $File::Find::name if -d }, $search ; for $dir ( @dirs ) { opendir $dh, $dir or do { warn "Cannot open '$dir' $!" ; next ; } ; opendir( DIR, "$dir" ) ; @files = readdir( DIR ) ; closedir( DIR ) ; foreach $file ( @files ) { print " $dir\$file\n"; if ( -f "$dir/$file") { $filesize = -s "$dir/$file" ; if ( $file ne "empty.txt" && $file ne "sample.txt" ) { print OUTF "Warning: $dir/$file has size ZERO\n" if ( $filesize == "0" ) ; } } } closedir( $dh ) ; } close OUTF ; exit 0;
Thanks,

In reply to 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.