in reply to regular expression help

It's difficult to help you when you've made it so difficult to understand what you want because of the poor formatting of your post. I've made my best shot, is this the sort of thing you want?
while ( <DATA> ) { next if m/(?:start up server)|(?:-- logging started)|(?:-- disconn +ected user)/; print } __DATA__ 081407 start up server 081407 -- fatal error in procedure 1 081407 -- disconnected user 081407 -- logging started 081407 -- not enough space

Output:

081407 -- fatal error in procedure 1 081407 -- not enough space

You should ask your friend to tell you how to format your posts, and read How do I compose an effective node title? and Writeup Formatting Tips.

Replies are listed 'Best First'.
Re^2: regular expression help
by wantamad (Initiate) on Aug 14, 2007 at 18:02 UTC
    sorry for the bad formatting. its my first time to use this. i was thinking more of somethingl ike this:
    $regex = qr/--/ if($thestring =~ $regex || $thestring !~ $regex) { unshift(@match, $thestring); }
    but the problem is the logfile is a bit dynamic and i dont know what errors i am going to get. i just know that "--" usually indicates an error but not all lines with "--" means that they are really errors. so in this sample log file:
    081407 start up server 081407 -- fatal error in procedure 1 081407 -- disconnected user 081407 -- logging started 081407 -- not enough space
    i just want to get
    081407 -- fatal error in procedure 1 081407 -- not enough space
    and disregard the rest like:
    081407 -- disconnected user 081407 -- logging started
    is there a way i can use it in qr// function? i guess something like this:
    1. get all occurrences of "--". 2. in those occurrences of "--" ignore those that have "logging" and " +disconnected" could it be place in a qr// function like: qr/-- || ~! logging,disconnected/ (wrong syntax of course) something like an ignore list.
    hope thats clearer
      but the problem is the logfile is a bit dynamic and i dont know what errors i am going to get. i just know that "--" usually indicates an error but not all lines with "--" means that they are really errors. so in this sample log file
      Well then, your first step is to find out either what you want, or what you don't want. No regular expression is going to solve that one for you.

      Thanks for taking the time to properly format your post. It is most appreciated.