On Dec 11, 2003, at 1:20 PM, [EMAIL PROTECTED] wrote: [..]
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...
[..]

Let's think about the problem here a bit more.

Step back and ask yourself

how does the (-e $filename) trick work?

Well it sort of depends upon the OS, yes, but basically
it's going to have to do the following basic solution

        a. get the directory portion of $filename
        b. open the directory 'block'
        c. rummage around in the list from the dirblock
                to compare the 'file' portion of filename

so given our time constraint, a 'few seconds' to a 'few minutes'
we are talking about something on the order of n waltz's
through the dirBlock filename list to (n*60) waltz to do a bunch
of cmp of strings...

So it would seem a bit more efficient to say,
        hey, why don't we just open the dirBlock once?
        I have perl and a strong RegEx Engine...

Now we move into the basic clock problem. Clearly
if we start a poll run at 2003.12.31.2359.59, and it runs
for more than one second we will be looking for the new
log file to be in, 2004.01.01.00NN.NN ....

The gooder news, of course is that we can also tighten
up our basic 'grep' string some here as well.

my $delta = ($endtime - $starttime)

        if ( $old_Y_M_D eq $new_YM_D )
                the YMD values are the same
                grow out the filename
        else
                handle different YMD values

        if ($old_hour = $new_hour)
                grow filname to Hour value

        if ( $delta < 60 )
                if ($old_minute = $new_minute )
                        grow filename down to minute level

What you are also beginning to bump your head into is the
underlying problem of using the file system a bit more
effectively to help streamline your process. If
you could fan out "N" discovery processes each writing
to "N" directories that are Each on "N" different
disk controllers.... Their writes would be simpler,
and Your Reads would be simpler too...

Just a bit of longer term strategic thinking....

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>




Reply via email to