in reply to Re^2: Manage Directory Structure
in thread Manage Directory Structure
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.
|
|---|