At 20:45 11/12/2003, you wrote:

>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?

yes this is right i need the most recent one... as after the log is written it takes a 
few or more seconds for the command to return.
the "discover" or delta can be from a few seconds to a few minits (depending on the 
number of elements configured on the device)



>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
>                };
>        };

this looks good to me i shall try it out tomorro, but i had a look on CPAN and found a 
golb module that may help???

>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.

there are a "lot" of file in the dir, they are cycled / cleaned up, by a scheduled job 
every week,
but some will be a month old (ones the result from a monthly scheduled job)

>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;


humm if i have this list, can i "grep" through and find the one that contains "key" 
(ie host name)
that would do the trick...


>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...
>


this could get messy as i could be running say 20 discovers and only after each one 
will the log file be ceated.
+new log could be created by non discover activities.

thanks for your help

Ritchie

>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>
>
>
>
>
>
>---
>Incoming mail is certified Virus Free.
>Checked by AVG anti-virus system (http://www.grisoft.com).
>Version: 6.0.537 / Virus Database: 332 - Release Date: 06/11/2003
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.537 / Virus Database: 332 - Release Date: 06/11/2003

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>

Reply via email to