in reply to Regex to end of a line from previous line

Maybe you don't need to know where the current (error) message ends, but just need to know where the next message starts?

Showing us some more lines of input (also in between <code>...</code> tags) might help us help you better. If the current message ends with a blank line, the following could be all you need:

while (<FILE>) { if (/^SQL/ .. /^$/) { print "Found error $_\n"; }; };

Also, instead of shelling out to date, I prefer POSIX::strftime, or localtime.

Replies are listed 'Best First'.
Re^2: Regex to end of a line from previous line
by bp4a (Initiate) on Sep 23, 2010 at 15:28 UTC

    Corion -- The file is overwritten each time there is an error, so there won't be a next error listed. This file just stores the error and sends that info in an email to us, then when it fails the next time it is overwritten with the new error message. I am just trying to get a history of the errors to show my TSM group what I am seeing with my DB backups. But without all the "online backup of blatty blah failed etc."

    Not sure if I am going to change the way I get the date/time stamp cause this is how we already capture this info in all the other scripts on all the other servers and it would probably be too much of a hassle to mess with right now. Thanks for the tip and response.

    Thansk -- bp4a

      So, how do you know that one message ended and the next message starts, then?