From: Philipp Traeder <[EMAIL PROTECTED]> > You're right - the problem I'm trying to solve is quite restricted - > and I'm very thankful for this ;-) Basically, I'm trying to write an > application that "recognizes" log file formats, so that the following > lines are identified as several manifestations of the same log > message: > > could not delete user 3248234 > could not delete user 2348723 > > or even > > failed to connect to primary server > failed to connect to secondary server > > What I would like to see is a count of how many "manifestations" of > each log message are being thrown, independently of the actual data > they might contain. Since I do not want to hardcode the log messages > into my application, I would like to generate regexes on the fly as > they are needed.
Well and how are you going to tell the program which messages to take as the same? Do you plan to teach the app as it reads the lines? Do you want it to ask which group is a line that doesn't match any of the regexps so far and have the regexp modified on the fly to match that line as well? Or what do you want to do? IMHO it might be best to use handmade regexps, just don't have them built into the application, but read from a config file. That is for each type of logs you'd have a file with something like this: delete_user=^could not delete user \d+ connect=^failed to connect to (?:primary|secondary) server ... read the file, compile the regexps with qr// and have the application try to match them and have the messages counted in the first group whose regexp matches. Do I make sense or am I babbling nonsense? Jenda ===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz ===== When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>