[HRPM] Multiline matching
Santiago Nieva
sgalayar at yahoo.com
Thu Mar 15 03:15:16 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
__________________________________________________
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