in reply to Re: regular expression help
in thread regular expression help

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

Replies are listed 'Best First'.
Re^3: regular expression help
by FunkyMonk (Bishop) on Aug 14, 2007 at 18:37 UTC
    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.