Perl wrote:
> 
> I am attempting to parse a log file that looks something like:
> 
> 759033281 TE18 <Vups_MsgStore> constructor - add to MDBTable
> EX:/O=MSGENG/OU=EUROPE/CN=RECIPIENTS/CN=PHARWOOD
> 759033281 TE18 <Vups_MsgStore> AddRef=2
> EX:/O=MSGENG/OU=EUROPE/CN=RECIPIENTS/CN=PHARWOOD
> 759033281 TE18 <MSM> S-REXCH-MSG-07
> 759033281 TE18 <MSM> S-REXCH-MSG-06
> 759033281 TE18 <MSM> C-REXCH-MSG-07
> 759033281 TE18 <MSM> C-REXCH-MSG-06
> 759033281 TE18 <VUPSMAPI> Vups_MailboxLogon done 0x0
> 759033281 TE18 <MSM> C-REXCH-MSG-06
> 759033281 TE18 <MSM> No timestamp for thread
> 759033281 TE18 <MsgLog>     IMAPISession::OpenMsgStore          M    109
> Q      0
> 
> The only lines I am interested in are ones that have "PHARWOOD" followed
> by a line that has "OpenMsgStore" in it.
> 
> If I could explain this in English, I would want to say:
> 
> "Search for an instance of "PHARWOOD" and once found print that line.
> Then search for the very next instance of "OpenMsgStore" that follows
> PHARWOOD (whether it be the next line or several lines down) and print
> that."
> 
> The code I have so far works but I don't understand how to change my
> Regex filter to change from PHARWOOD to OpenMsgStore and back again. Or
> is there a simpler method?

Something like this should work:

my $umlogs = 'z:';

local @ARGV = <$umlogs/*>;

my $found = 0;
while ( <> ) {
    if ( /PHARWOOD/ ) {
        print;
        $found = 1;
        }
    if ( $found and /OpenMsgStore/ ) {
        print;
        $found = 0;
        }
    }

__END__


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to