in reply to store regex in hash
I am trying (big emphasis on trying ) to write a script to parse log files, I thought it would be a good idea to store the regex in a hash table and use the event ID as the key. So that I can add to the hash table as new log messages types are added.
My problem is that I get the regex string working properly but when I put it in a variable it stops working, a quick example is the regex to extract the event ID
#this works: $current_line =~ q{\A.*? %(.*?): }xms; $event_id = $1; #this fails: $RGX_EVENTID = 'q{\A.*? %(.*?): }xms'; $current_line =~ $RGX_EVENTID; $event_id = $1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: store regex in hash
by graff (Chancellor) on Jul 03, 2011 at 18:08 UTC | |
by johngg (Canon) on Jul 04, 2011 at 09:40 UTC | |
|
Re^2: store regex in hash
by JavaFan (Canon) on Jul 03, 2011 at 20:26 UTC |