Re: Это, конечно, не шедевр... :-)

От: Maxim Polyakov <CGatePro_at_mx_ru>
Дата: Mon 24 Nov 2003 - 15:49:49 MSK

#!/usr/bin/perl

if(@ARGV eq 0)
{

    print "Usage: userstat.pl searchstring [log_file] [>outputfile]\n";     exit;
}

$searchstring = shift @ARGV;

if(@ARGV[0] ne '')
{

    $filename = shift @ARGV;

}

opendir(DIRECTORY,".");

foreach (sort readdir(DIRECTORY))
{

if((/(.*)(\.log)$/)&&(($filename eq '')||($filename eq $_))) {

$date=$1;

open(FILE, $_);

while(<FILE>)
{

    $flag=0;     

    $buffer='';

    if(/QUEUE\(\[([0-9]*)\]\) from <(.*)>,/)     {

        $searchsequence=$1;

        $buffer=$buffer.$date.":".$_;
        
        $searchposition=tell(FILE);
        
        if(/$searchstring/)
        {
        
            $flag=1;
            
        }
        
        while(<FILE>)
        {
        
            if(/DEQUEUER \[$searchsequence\]/)
            {
            
                $buffer=$buffer.$date.":".$_;
                
                if(/$searchstring/)
                {
                
                    $flag=1;
                
                }
            
            }
            
            if(/QUEUE\(\[$searchsequence\]\) deleted/)
            {
            
                $buffer=$buffer.$date.":".$_;
            
                last;
            
            }
        
        }    
        
        seek FILE, $searchposition, 0;
        
        if($flag)
        {
        
            print $buffer,"\n";
        
        }
        

    }

}

close(FILE);

}

}

closedir(DIRECTORY); Получено Mon Nov 24 12:49:37 2003

Этот архив был сгенерирован hypermail 2.1.8 : Tue 21 Feb 2006 - 03:14:38 MSK