first off: always use strictures (use strict; use warnings;).

my $out = "/home/users/user/tmp/$progname_$today.dat";

should be

my $out = "/home/users/user/tmp/${progname}_$today.dat";

or $progname_ will be seen as the variable name rather than $progname. Strictures should also force you to think a little more about lifetime of variables and how you pass information around to different parts of your program.

call_dir($p=1) ... sub call_dir { if ($p == 1) ... <p>would be better as:</p> <c> call_dir(1) ... sub call_dir { my ($p) = @_; if ($p == 1)

although passing an array into the find call would be even better:

my $main = "/home/users/user"; my @rootDirs = ("$main/tmp/", "$main/exe"); ... find ({wanted => \&data_for_path, follow=>1, follow_skip=>2}, @rootDir +s);

and avoids the interesting mismatch between the calls to call_dir and the implementation (3 calls, 2 valid return values).

However, I'd be inclined to read and parse today and yesterday's files in parallel to detect differences. That avoids having any more than a few lines of data in memory at any given time, but may make the parsing a little more interesting.

If instead you read the files in parallel as suggested above, but load a complete directory of files at a time into two arrays of lines (one for today's files and one for yesterday's) you could then use Algorithm::Diff to do the heavy lifting in differencing the two file sets. That limits the data in memory to one directory worth of files (x 2 - one image for each day), but probably simplifies the diff parsing substantially.


True laziness is hard work

In reply to Re^3: Manage Directory Structure by GrandFather
in thread Manage Directory Structure by boardryder

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.