On Dec 11, 2003, at 11:49 AM, [EMAIL PROTECTED] wrote: [..]
[..]there is probably a much better way of doing all this i am working on the checkResults sub. it should find the pollerAudit log created by the main process (discover) the file format for the log file is pollerAudit.M.D.Y.h.m.s.lan (MDYhms being month day year hrs min sec)
This Might be a good time to step back and look at this problem in terms of 'algorithm' then worry about the code side. Since, while, yes, I can 'read' your code, it may help to begin with 'what do you really want/need'?
You are passing in two time values into a function, so that you can try to find the 'files' that would be made between those times, yes? In particular, you are looking for the most recent one, yes?
IF you only need the most recent one, then your basic iteration loop could be simplified with say
for ( my ($fTime) = $highFileName; $fTime = $lowFileName; $fTime--) { #my($fullFileName)="pollerAudit.$fileDate.$_.log"; # make one substitution my($fullFileName)="/$NH_HOME/log/pollerAudit.$fileDate.$fTime.log"; if (-e "$fullFileName") { open UPDATELOG, "$fullFileName"; my($reslutsLog) = <UPDATELOG>; close UPDATELOG; last; # break out of the loop we found one }; };
The question really is how many files will be in the 'log' directory - who is cleaning them up - and the actual 'delta' between the $highFileName time value, and the actual 'youngest file' in the directory.
Why not Open the directory with say opendir() and get the list of files in it? then use the readdir() and 'grep' type tricks:
opendir(DIR, $some_dir) || die "can't opendir $some_dir: $!";
@today_files = grep {$_ =~ /^pollerAudit.$fileDate.*\.log$/ } readdir(DIR);
closedir DIR;
Then all you need to do is 'sort' that @today_files array... You might think of solving that problem with 'map', since you could then have a hash of 'existing files' and would have made one read of 'the directory block' and the rest is in core memory manipulations...
ciao drieux
---
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>