[HRPM] Multiline matching

Santiago Nieva sgalayar at yahoo.com
Thu Mar 15 03:13:02 CST 2001


Hi again, 
Thanks to everyone (especially Branson and collin).
I´ve learned a couple of very useful tips !!.
  This is finally what I did:

<CODE>
#!/bin/perl
 
$logfile="/opt/....";
open(LF,"< $logfile") or die "cannot open
$logfile:$!";

while ( $twolines = <LF> ) {
   $twolines .= <LF>;
   ($message,$date)=($twolines =~ /(.*)\n(.*)/); 
# - This regex is so funny, but it works for me - 
# In the next line, I filter: by date, and a key word
# like "user" 
print "$message: $date\n" if ( ( $date =~
/2001-03-07/)       && ($message =~ /user/ ));
# I´ll probably use two parameters for dates and key #
word  
}

</CODE>
regards
Santi
 
--- Branson Matheson <Branson.Matheson at FergInc.com>
wrote:
>  I already sent him a script ;-)
> 
> On Wed, Mar 14, 2001 at 01:18:44PM -0500,Christopher
> Hicks did mutter:
> > On Wed, 14 Mar 2001, Collin Cusce wrote:
> > > Ok, I'm a bit confused...
> > > This is what you sent us before:
> > >     2001-03-07 msgID=4875876856     
> > >     User "nnnnnn" does not exists   
> > >     2001-03-07 msg.....
> > >     The applica....
> > > Is that not how the log file looks? Or is there
> an error in my code (quite possible, indeed).
> > 
> > Would it be possible for a sanitized log file to
> be posted somewhere for
> > people to play with?  E-mail it to me and I'll put
> it on the web
> > somewhere.
> > 
> > -- 
> > </chris>
> > 
> > Those who cannot remember the past are doomed to
> buy Microsoft products.
> > 
> 
>   - branson
> 
>
-------------------------------------------------------------------------------
> Branson Matheson                       "If you are
> falling off of a mountain,
> Manager, Risk and Information Security   You may as
> well try to fly." 
> Ferguson Enterprises, Inc.               - Delenn,
> Minbari Ambassador 
>            ( $statements = <BRANSON> ) !~ /Corporate
Opinion/;


__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - Buy the things you want at great prices.
http://auctions.yahoo.com/



More information about the Norfolk-pm mailing list