It sounds like you want to store the results between runs of your perl script. In that case, what you suggest sounds reasonable. I would encapsulate this in either a function or a module, something like
sub invokeCmd {
my ($cmd) = @_;
# assuming full path for cmd, change path from
# cmd area to results area
my $curResultsFile=$cmd."res";
# stat the file, check for existence, and 'last mod' value
if ($too_old) {
# re-run command and store results in $curResultsFile
}
my $res;
open $res, $curResultsFile or die "could not open results: $!\n";
return $res;
}
Update What Kyle suggests would work just fine as well. Depending on how long your commands take to run, and how long you wish to store the results, You should probably avoid storing the results under /tmp (the default for Cache::FileCache), as a reboot deletes everything there.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.