--- "Yacketta, Ronald" <[EMAIL PROTECTED]> wrote:

Hmm... some of this code looks familiar, lol....

> $lookFor="Test App Finished|Fault
> 2-0|ORA-|Bind|SystemError|SystemException|Communication|ORBA|Get Q
> Error";
> opendir DIR, "../logs/set1/" or die "Can't open ../logs/set1/: $!";
> @allFiles = readdir DIR;
> closedir DIR;
> 
> foreach (@allFiles) {
>         if ( $_ !~ /logger/ ) { print "skipping: $_\n"; next; }
>         if( ($count % 3) == 0 ) {
>                 push(@logFiles1,"../logs/set1/" . $_);
>                 print "Hey I am in logFiles1!!! ($_)\n";
>         } else {
>                 if ( ($count % 2 ) == 0 ) {
>                         push(@logFiles2,"../logs/set1/" . $_);
>                         print "Hey I am in logFiles2!!! ($_)\n";
>                 } else {
>                         push(@logFiles3,"../logs/set1/" . $_);
>                         print "Hey I am in logFiles3!!! ($_)\n";
>                 }
>         }
>         $count++;
> }

Try splice here:

   my $third = int(scalar @allfiles / 3);
   my @set   = ( [ splice @allfiles, 0, $third ], # first third
                 [ splice @allfiles, 0, $third ], # second third
                 [ @allfiles ],                   # the rest.
   );

Now you can loop through the elements of @set as the constituent
arrays, like this:

   for (0..$#set) {
     exec 'egrep', $lookFor, @set[$_] unless $pid=fork;
     # maybe check $pid here....
   }

That may complain, but since $set[$_] is an array ref, it shouldn't....

On the other hand, if you don't want to do that....

> @CMD = ( "egrep", "egrep", "egrep" );
> @LOGS = ( \@logFiles1, \@logFiles2, \@logFiles3 );
> print " count: " . @logFiles1 . "\n";;
> print " count: " . @logFiles2 . "\n";;
> print " count: " . @logFiles3 . "\n";;
> #exit();
>
> sub spawn ($) {
>    return 0 unless @CMD;
>    unless ($cmd = shift @CMD) { # read next command from cmdfile
>       warn "\nDone with command $cmd\n";
>       return undef @CMD;
>    }
>    chomp $cmd;

In the next two lines:

>         print "@{$LOGS[$_]}\n";
>    exec $cmd, $lookFor, @{$LOGS[$_]}  unless $pid=fork; # fork new

What's the value of $_ ???




__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

Reply via email to