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? Any help welcome, --Paul ------------------------------- $umlogs = "z\:"; opendir (DIR, "$umlogs") || die "Unable to open $umlogs because:\n$!\n"; @dirs = readdir(DIR); foreach $dir (@dirs) { if ($dir =~/^V_DEBUG/i) { open (LOGFILE, "$umlogs\\$dir") || die "unable to open $dir because:\n$!\n"; print "$umlogs\\$dir\n"; while (<LOGFILE>) { my @fields = split / /; if (/PHARWOOD/) { print $_; } } } }